300 lines
9.6 KiB
Lua
300 lines
9.6 KiB
Lua
-- Debug Helper for GaG
|
|
-- ใช้เพื่อดูข้อมูลในเกมและ debug Auto Farm
|
|
|
|
print("=== GaG Debug Helper ===")
|
|
|
|
local Players = game:GetService("Players")
|
|
local Workspace = game:GetService("Workspace")
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
|
|
local Player = Players.LocalPlayer
|
|
|
|
-- ฟังก์ชัน Debug
|
|
local function DebugWorkspace()
|
|
print("\n🌍 === WORKSPACE STRUCTURE ===")
|
|
|
|
print("\n📁 Main Children:")
|
|
for _, child in pairs(Workspace:GetChildren()) do
|
|
print(" - " .. child.Name .. " (" .. child.ClassName .. ")")
|
|
|
|
if child.Name:lower():find("plot") then
|
|
print(" 🎯 PLOT FOUND!")
|
|
for _, subchild in pairs(child:GetChildren()) do
|
|
print(" - " .. subchild.Name .. " (" .. subchild.ClassName .. ")")
|
|
end
|
|
end
|
|
end
|
|
|
|
print("\n🔍 Searching for 'Plot' objects:")
|
|
for _, obj in pairs(Workspace:GetDescendants()) do
|
|
if obj.Name:lower():find("plot") then
|
|
print(" 📍 " .. obj:GetFullName())
|
|
if obj:FindFirstChild("Owner") then
|
|
print(" 👤 Owner: " .. tostring(obj.Owner.Value))
|
|
print(" 🏠 Is mine: " .. tostring(obj.Owner.Value == Player))
|
|
end
|
|
if obj:FindFirstChild("Plant") then
|
|
print(" 🌱 Has Plant")
|
|
local plant = obj:FindFirstChild("Plant")
|
|
for _, attr in pairs({"Grown", "IsGrown", "Ready"}) do
|
|
if plant:FindFirstChild(attr) then
|
|
print(" ✅ " .. attr .. ": " .. tostring(plant[attr].Value))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
local function DebugRemoteEvents()
|
|
print("\n📡 === REMOTE EVENTS ===")
|
|
|
|
local events = {}
|
|
for _, obj in pairs(ReplicatedStorage:GetDescendants()) do
|
|
if obj:IsA("RemoteEvent") or obj:IsA("RemoteFunction") then
|
|
table.insert(events, {obj, obj:GetFullName()})
|
|
end
|
|
end
|
|
|
|
print("\n📋 All RemoteEvents/Functions:")
|
|
for i, event in pairs(events) do
|
|
print(string.format("%d. %s - %s", i, event[1].ClassName, event[1].Name))
|
|
print(" 📍 " .. event[2])
|
|
end
|
|
|
|
print("\n🎯 Farm-related events:")
|
|
for _, event in pairs(events) do
|
|
local name = event[1].Name:lower()
|
|
if name:find("plant") or name:find("harvest") or name:find("sell") or
|
|
name:find("buy") or name:find("farm") or name:find("shop") then
|
|
print(" 🔥 " .. event[1].Name .. " (" .. event[1].ClassName .. ")")
|
|
end
|
|
end
|
|
end
|
|
|
|
local function DebugPlayerData()
|
|
print("\n👤 === PLAYER DATA ===")
|
|
|
|
print("Player Name: " .. Player.Name)
|
|
print("UserId: " .. Player.UserId)
|
|
|
|
-- Check leaderstats
|
|
if Player:FindFirstChild("leaderstats") then
|
|
print("\n💰 Leaderstats:")
|
|
for _, stat in pairs(Player.leaderstats:GetChildren()) do
|
|
print(" " .. stat.Name .. ": " .. tostring(stat.Value))
|
|
end
|
|
end
|
|
|
|
-- Check Data folder
|
|
if Player:FindFirstChild("Data") then
|
|
print("\n💾 Data:")
|
|
for _, data in pairs(Player.Data:GetChildren()) do
|
|
print(" " .. data.Name .. ": " .. tostring(data.Value))
|
|
end
|
|
end
|
|
|
|
-- Check PlayerGui
|
|
print("\n🖥️ PlayerGui:")
|
|
for _, gui in pairs(Player.PlayerGui:GetChildren()) do
|
|
if not gui.Name:find("Core") then
|
|
print(" " .. gui.Name)
|
|
end
|
|
end
|
|
end
|
|
|
|
local function TestPlotFinding()
|
|
print("\n🧪 === TESTING PLOT FINDING ===")
|
|
|
|
local plots = {}
|
|
|
|
-- Method 1: Plots folder
|
|
local plotsFolder = Workspace:FindFirstChild("Plots")
|
|
if plotsFolder then
|
|
print("✅ Found Plots folder")
|
|
for _, plot in pairs(plotsFolder:GetChildren()) do
|
|
if plot:FindFirstChild("Owner") and plot.Owner.Value == Player then
|
|
table.insert(plots, plot)
|
|
print(" 🏠 My plot: " .. plot.Name)
|
|
end
|
|
end
|
|
else
|
|
print("❌ No Plots folder found")
|
|
end
|
|
|
|
-- Method 2: Direct search
|
|
if #plots == 0 then
|
|
print("🔍 Searching workspace directly...")
|
|
for _, obj in pairs(Workspace:GetChildren()) do
|
|
if obj.Name:lower():find("plot") and obj:FindFirstChild("Owner") then
|
|
if obj.Owner.Value == Player then
|
|
table.insert(plots, obj)
|
|
print(" 🏠 My plot: " .. obj.Name)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- Method 3: Deep search
|
|
if #plots == 0 then
|
|
print("🔍 Deep searching...")
|
|
for _, obj in pairs(Workspace:GetDescendants()) do
|
|
if obj.Name:lower():find("plot") and obj:FindFirstChild("Owner") then
|
|
if obj.Owner.Value == Player then
|
|
table.insert(plots, obj)
|
|
print(" 🏠 My plot: " .. obj.Name)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
print("\n📊 Results:")
|
|
print("Total plots found: " .. #plots)
|
|
|
|
for i, plot in pairs(plots) do
|
|
print("\nPlot " .. i .. ": " .. plot.Name)
|
|
print(" 📍 Position: " .. tostring(plot.Position))
|
|
|
|
if plot:FindFirstChild("Plant") then
|
|
local plant = plot.Plant
|
|
print(" 🌱 Has plant")
|
|
|
|
-- Check growth status
|
|
local isGrown = false
|
|
if plant:FindFirstChild("Grown") then
|
|
isGrown = plant.Grown.Value
|
|
print(" 📈 Grown: " .. tostring(isGrown))
|
|
end
|
|
if plant:FindFirstChild("IsGrown") then
|
|
isGrown = plant.IsGrown.Value
|
|
print(" 📈 IsGrown: " .. tostring(isGrown))
|
|
end
|
|
if plant:FindFirstChild("Ready") then
|
|
isGrown = plant.Ready.Value
|
|
print(" 📈 Ready: " .. tostring(isGrown))
|
|
end
|
|
|
|
-- Check attributes
|
|
for _, attr in pairs(plant:GetAttributes()) do
|
|
print(" 🏷️ Attribute: " .. tostring(attr))
|
|
end
|
|
|
|
else
|
|
print(" 🌱 No plant")
|
|
end
|
|
end
|
|
|
|
return plots
|
|
end
|
|
|
|
local function TestRemoteEvents()
|
|
print("\n🧪 === TESTING REMOTE EVENTS ===")
|
|
|
|
-- Find farm-related events
|
|
local farmEvents = {}
|
|
for _, obj in pairs(ReplicatedStorage:GetDescendants()) do
|
|
if obj:IsA("RemoteEvent") then
|
|
local name = obj.Name:lower()
|
|
if name:find("plant") or name:find("harvest") or name:find("sell") then
|
|
table.insert(farmEvents, obj)
|
|
end
|
|
end
|
|
end
|
|
|
|
print("Farm events found: " .. #farmEvents)
|
|
|
|
for _, event in pairs(farmEvents) do
|
|
print(" 🎯 " .. event.Name)
|
|
|
|
-- Try to listen to the event (for debugging)
|
|
local connection
|
|
connection = event.OnClientEvent:Connect(function(...)
|
|
print(" 📥 " .. event.Name .. " fired with:", ...)
|
|
connection:Disconnect()
|
|
end)
|
|
end
|
|
|
|
return farmEvents
|
|
end
|
|
|
|
-- Execute all debug functions
|
|
DebugWorkspace()
|
|
DebugRemoteEvents()
|
|
DebugPlayerData()
|
|
local plots = TestPlotFinding()
|
|
local events = TestRemoteEvents()
|
|
|
|
-- Store results globally for inspection
|
|
_G.DebugResults = {
|
|
plots = plots,
|
|
events = events,
|
|
workspace = Workspace,
|
|
player = Player
|
|
}
|
|
|
|
print("\n✅ Debug completed! Results stored in _G.DebugResults")
|
|
print("📊 Found " .. #plots .. " plots and " .. #events .. " farm events")
|
|
print("\n💡 TIP: Check the console output above for detailed information!")
|
|
|
|
-- Create simple debug UI
|
|
local function CreateDebugUI()
|
|
local ScreenGui = Instance.new("ScreenGui")
|
|
ScreenGui.Name = "DebugUI"
|
|
ScreenGui.Parent = Player.PlayerGui
|
|
|
|
local Frame = Instance.new("Frame")
|
|
Frame.Parent = ScreenGui
|
|
Frame.Size = UDim2.new(0, 300, 0, 200)
|
|
Frame.Position = UDim2.new(1, -320, 0, 20)
|
|
Frame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
|
|
Frame.BorderSizePixel = 2
|
|
Frame.BorderColor3 = Color3.fromRGB(255, 255, 0)
|
|
|
|
local Title = Instance.new("TextLabel")
|
|
Title.Parent = Frame
|
|
Title.Size = UDim2.new(1, 0, 0, 30)
|
|
Title.BackgroundColor3 = Color3.fromRGB(255, 255, 0)
|
|
Title.Text = "GaG Debug Info"
|
|
Title.Font = Enum.Font.SourceSansBold
|
|
Title.TextSize = 14
|
|
Title.TextColor3 = Color3.fromRGB(0, 0, 0)
|
|
|
|
local Info = Instance.new("TextLabel")
|
|
Info.Parent = Frame
|
|
Info.Position = UDim2.new(0, 10, 0, 40)
|
|
Info.Size = UDim2.new(1, -20, 1, -50)
|
|
Info.BackgroundTransparency = 1
|
|
Info.Text = string.format(
|
|
"Plots Found: %d\nFarm Events: %d\nPlayer: %s\nPlaceId: %d",
|
|
#plots, #events, Player.Name, game.PlaceId
|
|
)
|
|
Info.Font = Enum.Font.SourceSans
|
|
Info.TextSize = 12
|
|
Info.TextColor3 = Color3.fromRGB(255, 255, 255)
|
|
Info.TextYAlignment = Enum.TextYAlignment.Top
|
|
Info.TextXAlignment = Enum.TextXAlignment.Left
|
|
|
|
local CloseButton = Instance.new("TextButton")
|
|
CloseButton.Parent = Frame
|
|
CloseButton.Size = UDim2.new(0, 20, 0, 20)
|
|
CloseButton.Position = UDim2.new(1, -25, 0, 5)
|
|
CloseButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
|
|
CloseButton.Text = "X"
|
|
CloseButton.Font = Enum.Font.SourceSansBold
|
|
CloseButton.TextSize = 12
|
|
CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
|
|
|
|
CloseButton.MouseButton1Click:Connect(function()
|
|
ScreenGui:Destroy()
|
|
end)
|
|
|
|
-- Auto-close after 10 seconds
|
|
wait(10)
|
|
if ScreenGui.Parent then
|
|
ScreenGui:Destroy()
|
|
end
|
|
end
|
|
|
|
spawn(CreateDebugUI)
|
|
|
|
return _G.DebugResults |