Roblox-Bot-Lua/Main/GaG/SimpleUI_v2.lua
2025-07-21 10:41:54 +07:00

585 lines
19 KiB
Lua

-- Simple GaG UI v2.0 - Working Version
-- UI ที่ทำงานได้จริงสำหรับเกม Grow a Garden
-- ตรวจสอบว่าอยู่ในเกม GaG
if game.PlaceId ~= 4442272183 then
warn("This script only works in Grow a Garden!")
return
end
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
-- ป้องกันการรันซ้ำ
if _G.SimpleGaGUILoaded then
warn("Simple GaG UI is already loaded!")
return
end
_G.SimpleGaGUILoaded = true
-- Settings
local Settings = {
AutoFarm = false,
AutoSell = false,
SelectedPlant = "Carrot",
FarmDelay = 1,
SellDelay = 5,
DebugMode = true
}
-- Debug Function
local function DebugPrint(text)
if Settings.DebugMode then
print("[GaG Debug] " .. tostring(text))
end
end
-- สร้าง Notification
local function Notify(title, text, duration)
game:GetService("StarterGui"):SetCore("SendNotification", {
Title = title or "GaG Auto Farm",
Text = text or "",
Duration = duration or 3
})
end
-- หา Game Events และ Functions
local GameEvents = {}
local function FindGameEvents()
DebugPrint("กำลังค้นหา Game Events...")
for _, obj in pairs(ReplicatedStorage:GetDescendants()) do
if obj:IsA("RemoteEvent") or obj:IsA("RemoteFunction") then
local name = obj.Name:lower()
if name:find("plant") or name:find("harvest") or name:find("sell") or
name:find("buy") or name:find("shop") or name:find("farm") then
GameEvents[obj.Name] = obj
DebugPrint("พบ Event: " .. obj.Name .. " (" .. obj.ClassName .. ")")
end
end
end
DebugPrint("พบ Events ทั้งหมด: " .. #GameEvents)
end
-- หา Player Plots
local function GetPlayerPlots()
local plots = {}
-- วิธีที่ 1: หาจาก Workspace/Plots
local plotsFolder = Workspace:FindFirstChild("Plots")
if plotsFolder then
for _, plot in pairs(plotsFolder:GetChildren()) do
if plot:FindFirstChild("Owner") and plot.Owner.Value == Player then
table.insert(plots, plot)
end
end
end
-- วิธีที่ 2: หาโดยตรงใน Workspace
if #plots == 0 then
for _, obj in pairs(Workspace:GetDescendants()) do
if obj.Name:find("Plot") and obj:FindFirstChild("Owner") then
if obj.Owner.Value == Player then
table.insert(plots, obj)
end
end
end
end
DebugPrint("พบ Player Plots: " .. #plots)
return plots
end
-- ตรวจสอบว่าพืชโตแล้วหรือยัง
local function IsPlantReady(plant)
if not plant then return false end
-- ตรวจสอบหลายวิธี
if plant:FindFirstChild("IsGrown") then
return plant.IsGrown.Value
elseif plant:FindFirstChild("Grown") then
return plant.Grown.Value
elseif plant:FindFirstChild("Ready") then
return plant.Ready.Value
elseif plant:GetAttribute("IsGrown") then
return plant:GetAttribute("IsGrown")
elseif plant:GetAttribute("Grown") then
return plant:GetAttribute("Grown")
elseif plant:GetAttribute("Ready") then
return plant:GetAttribute("Ready")
end
return false
end
-- เก็บพืช
local function HarvestPlant(plot, plant)
local success = false
-- วิธีที่ 1: ลอง RemoteEvents
for name, event in pairs(GameEvents) do
if name:lower():find("harvest") or name:lower():find("collect") then
local worked = pcall(function()
if event:IsA("RemoteEvent") then
event:FireServer(plot)
elseif event:IsA("RemoteFunction") then
event:InvokeServer(plot)
end
end)
if worked then
success = true
DebugPrint("เก็บพืชสำเร็จด้วย: " .. name)
break
end
end
end
-- วิธีที่ 2: ClickDetector
if not success and plant:FindFirstChild("ClickDetector") then
fireclickdetector(plant.ClickDetector)
success = true
DebugPrint("เก็บพืชด้วย ClickDetector")
end
-- วิธีที่ 3: ProximityPrompt
if not success then
local prompt = plant:FindFirstChildOfClass("ProximityPrompt")
if prompt then
fireproximityprompt(prompt)
success = true
DebugPrint("เก็บพืชด้วย ProximityPrompt")
end
end
return success
end
-- ปลูกพืช
local function PlantSeed(plot, seedName)
local success = false
-- วิธีที่ 1: ลอง RemoteEvents
for name, event in pairs(GameEvents) do
if name:lower():find("plant") or name:lower():find("buy") or name:lower():find("seed") then
local worked = pcall(function()
if event:IsA("RemoteEvent") then
event:FireServer(seedName, plot)
event:FireServer(plot, seedName)
event:FireServer("PlantSeed", seedName, plot)
elseif event:IsA("RemoteFunction") then
event:InvokeServer(seedName, plot)
event:InvokeServer(plot, seedName)
end
end)
if worked then
success = true
DebugPrint("ปลูกพืชสำเร็จด้วย: " .. name)
break
end
end
end
-- วิธีที่ 2: ClickDetector ใน plot
if not success and plot:FindFirstChild("ClickDetector") then
fireclickdetector(plot.ClickDetector)
success = true
DebugPrint("ปลูกพืชด้วย ClickDetector")
end
return success
end
-- ขายของ
local function SellItems()
local success = false
-- วิธีที่ 1: ลอง RemoteEvents
for name, event in pairs(GameEvents) do
if name:lower():find("sell") or name:lower():find("shop") then
local worked = pcall(function()
if event:IsA("RemoteEvent") then
event:FireServer()
event:FireServer("SellAll")
elseif event:IsA("RemoteFunction") then
event:InvokeServer()
event:InvokeServer("SellAll")
end
end)
if worked then
success = true
DebugPrint("ขายสำเร็จด้วย: " .. name)
break
end
end
end
-- วิธีที่ 2: หาพื้นที่ขาย
if not success then
for _, obj in pairs(Workspace:GetDescendants()) do
if obj.Name:lower():find("sell") or obj.Name:lower():find("shop") then
-- ลอง ClickDetector
local clickDetector = obj:FindFirstChildOfClass("ClickDetector")
if clickDetector then
fireclickdetector(clickDetector)
success = true
DebugPrint("ขายด้วย ClickDetector: " .. obj.Name)
break
end
-- ลอง ProximityPrompt
local prompt = obj:FindFirstChildOfClass("ProximityPrompt")
if prompt then
fireproximityprompt(prompt)
success = true
DebugPrint("ขายด้วย ProximityPrompt: " .. obj.Name)
break
end
end
end
end
return success
end
-- Auto Farm Function
local FarmConnection
local function StartAutoFarm()
if FarmConnection then
FarmConnection:Disconnect()
end
DebugPrint("เริ่ม Auto Farm")
Notify("Auto Farm", "เริ่มฟาร์มอัตโนมัติ")
FarmConnection = RunService.Heartbeat:Connect(function()
if not Settings.AutoFarm then
return
end
local success, error = pcall(function()
local plots = GetPlayerPlots()
if #plots == 0 then
DebugPrint("ไม่พบ plots ของผู้เล่น")
return
end
for i, plot in pairs(plots) do
local plant = plot:FindFirstChild("Plant")
if plant then
-- ตรวจสอบว่าพืชโตแล้ว
if IsPlantReady(plant) then
DebugPrint("เก็บพืชใน Plot " .. i)
HarvestPlant(plot, plant)
wait(0.3)
else
DebugPrint("พืชยังไม่โต Plot " .. i)
end
else
-- ปลูกพืชใหม่
DebugPrint("ปลูกพืชใหม่ใน Plot " .. i .. ": " .. Settings.SelectedPlant)
PlantSeed(plot, Settings.SelectedPlant)
wait(0.3)
end
end
end)
if not success then
DebugPrint("Auto Farm Error: " .. tostring(error))
end
wait(Settings.FarmDelay)
end)
end
local function StopAutoFarm()
if FarmConnection then
FarmConnection:Disconnect()
FarmConnection = nil
end
DebugPrint("หยุด Auto Farm")
Notify("Auto Farm", "หยุดฟาร์มอัตโนมัติ")
end
-- Auto Sell Function
local SellConnection
local function StartAutoSell()
if SellConnection then
SellConnection:Disconnect()
end
DebugPrint("เริ่ม Auto Sell")
Notify("Auto Sell", "เริ่มขายอัตโนมัติ")
SellConnection = RunService.Heartbeat:Connect(function()
if not Settings.AutoSell then
return
end
local success, error = pcall(function()
if SellItems() then
DebugPrint("ขายสำเร็จ")
else
DebugPrint("ไม่สามารถขายได้")
end
end)
if not success then
DebugPrint("Auto Sell Error: " .. tostring(error))
end
wait(Settings.SellDelay)
end)
end
local function StopAutoSell()
if SellConnection then
SellConnection:Disconnect()
SellConnection = nil
end
DebugPrint("หยุด Auto Sell")
Notify("Auto Sell", "หยุดขายอัตโนมัติ")
end
-- สร้าง UI
local function CreateUI()
-- ScreenGui
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "SimpleGaGUI_v2"
ScreenGui.Parent = PlayerGui
ScreenGui.ResetOnSpawn = false
-- Main Frame
local MainFrame = Instance.new("Frame")
MainFrame.Name = "MainFrame"
MainFrame.Parent = ScreenGui
MainFrame.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
MainFrame.BorderColor3 = Color3.fromRGB(0, 150, 255)
MainFrame.BorderSizePixel = 2
MainFrame.Position = UDim2.new(0.05, 0, 0.05, 0)
MainFrame.Size = UDim2.new(0, 300, 0, 400)
MainFrame.Active = true
MainFrame.Draggable = true
-- Title
local Title = Instance.new("TextLabel")
Title.Parent = MainFrame
Title.BackgroundColor3 = Color3.fromRGB(0, 150, 255)
Title.BorderSizePixel = 0
Title.Size = UDim2.new(1, 0, 0, 25)
Title.Font = Enum.Font.SourceSansBold
Title.Text = "Simple GaG Auto Farm v2"
Title.TextColor3 = Color3.fromRGB(255, 255, 255)
Title.TextSize = 14
-- Close Button
local CloseButton = Instance.new("TextButton")
CloseButton.Parent = Title
CloseButton.BackgroundColor3 = Color3.fromRGB(255, 50, 50)
CloseButton.BorderSizePixel = 0
CloseButton.Position = UDim2.new(1, -25, 0, 0)
CloseButton.Size = UDim2.new(0, 25, 0, 25)
CloseButton.Font = Enum.Font.SourceSansBold
CloseButton.Text = "X"
CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
CloseButton.TextSize = 12
-- Content
local Content = Instance.new("Frame")
Content.Parent = MainFrame
Content.BackgroundTransparency = 1
Content.Position = UDim2.new(0, 10, 0, 35)
Content.Size = UDim2.new(1, -20, 1, -45)
-- Auto Farm Toggle
local FarmLabel = Instance.new("TextLabel")
FarmLabel.Parent = Content
FarmLabel.BackgroundTransparency = 1
FarmLabel.Position = UDim2.new(0, 0, 0, 10)
FarmLabel.Size = UDim2.new(0.7, 0, 0, 25)
FarmLabel.Font = Enum.Font.SourceSans
FarmLabel.Text = "Auto Farm:"
FarmLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
FarmLabel.TextSize = 14
FarmLabel.TextXAlignment = Enum.TextXAlignment.Left
local FarmToggle = Instance.new("TextButton")
FarmToggle.Parent = Content
FarmToggle.BackgroundColor3 = Color3.fromRGB(255, 50, 50)
FarmToggle.BorderSizePixel = 0
FarmToggle.Position = UDim2.new(0.7, 0, 0, 10)
FarmToggle.Size = UDim2.new(0.3, 0, 0, 25)
FarmToggle.Font = Enum.Font.SourceSans
FarmToggle.Text = "OFF"
FarmToggle.TextColor3 = Color3.fromRGB(255, 255, 255)
FarmToggle.TextSize = 12
-- Plant Selection
local PlantLabel = Instance.new("TextLabel")
PlantLabel.Parent = Content
PlantLabel.BackgroundTransparency = 1
PlantLabel.Position = UDim2.new(0, 0, 0, 45)
PlantLabel.Size = UDim2.new(1, 0, 0, 20)
PlantLabel.Font = Enum.Font.SourceSans
PlantLabel.Text = "Selected Plant: " .. Settings.SelectedPlant
PlantLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
PlantLabel.TextSize = 12
PlantLabel.TextXAlignment = Enum.TextXAlignment.Left
-- Plant Buttons
local plants = {"Carrot", "Strawberry", "Tomato", "Corn", "Apple"}
for i, plant in ipairs(plants) do
local PlantButton = Instance.new("TextButton")
PlantButton.Parent = Content
PlantButton.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
PlantButton.BorderSizePixel = 0
PlantButton.Position = UDim2.new(0, (i-1) * 55, 0, 70)
PlantButton.Size = UDim2.new(0, 50, 0, 30)
PlantButton.Font = Enum.Font.SourceSans
PlantButton.Text = plant
PlantButton.TextColor3 = Color3.fromRGB(255, 255, 255)
PlantButton.TextSize = 10
PlantButton.MouseButton1Click:Connect(function()
Settings.SelectedPlant = plant
PlantLabel.Text = "Selected Plant: " .. plant
DebugPrint("เลือกพืช: " .. plant)
end)
end
-- Auto Sell Toggle
local SellLabel = Instance.new("TextLabel")
SellLabel.Parent = Content
SellLabel.BackgroundTransparency = 1
SellLabel.Position = UDim2.new(0, 0, 0, 115)
SellLabel.Size = UDim2.new(0.7, 0, 0, 25)
SellLabel.Font = Enum.Font.SourceSans
SellLabel.Text = "Auto Sell:"
SellLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
SellLabel.TextSize = 14
SellLabel.TextXAlignment = Enum.TextXAlignment.Left
local SellToggle = Instance.new("TextButton")
SellToggle.Parent = Content
SellToggle.BackgroundColor3 = Color3.fromRGB(255, 50, 50)
SellToggle.BorderSizePixel = 0
SellToggle.Position = UDim2.new(0.7, 0, 0, 115)
SellToggle.Size = UDim2.new(0.3, 0, 0, 25)
SellToggle.Font = Enum.Font.SourceSans
SellToggle.Text = "OFF"
SellToggle.TextColor3 = Color3.fromRGB(255, 255, 255)
SellToggle.TextSize = 12
-- Status Display
local StatusFrame = Instance.new("Frame")
StatusFrame.Parent = Content
StatusFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
StatusFrame.BorderColor3 = Color3.fromRGB(70, 70, 70)
StatusFrame.BorderSizePixel = 1
StatusFrame.Position = UDim2.new(0, 0, 0, 150)
StatusFrame.Size = UDim2.new(1, 0, 0, 150)
local StatusLabel = Instance.new("TextLabel")
StatusLabel.Parent = StatusFrame
StatusLabel.BackgroundTransparency = 1
StatusLabel.Size = UDim2.new(1, 0, 1, 0)
StatusLabel.Font = Enum.Font.SourceSans
StatusLabel.Text = "Status: Ready"
StatusLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
StatusLabel.TextSize = 11
StatusLabel.TextYAlignment = Enum.TextYAlignment.Top
-- Event Handlers
FarmToggle.MouseButton1Click:Connect(function()
Settings.AutoFarm = not Settings.AutoFarm
if Settings.AutoFarm then
FarmToggle.BackgroundColor3 = Color3.fromRGB(50, 255, 50)
FarmToggle.Text = "ON"
StartAutoFarm()
else
FarmToggle.BackgroundColor3 = Color3.fromRGB(255, 50, 50)
FarmToggle.Text = "OFF"
StopAutoFarm()
end
end)
SellToggle.MouseButton1Click:Connect(function()
Settings.AutoSell = not Settings.AutoSell
if Settings.AutoSell then
SellToggle.BackgroundColor3 = Color3.fromRGB(50, 255, 50)
SellToggle.Text = "ON"
StartAutoSell()
else
SellToggle.BackgroundColor3 = Color3.fromRGB(255, 50, 50)
SellToggle.Text = "OFF"
StopAutoSell()
end
end)
CloseButton.MouseButton1Click:Connect(function()
StopAutoFarm()
StopAutoSell()
ScreenGui:Destroy()
_G.SimpleGaGUILoaded = false
end)
-- Status Update
spawn(function()
while ScreenGui.Parent do
local plots = GetPlayerPlots()
local plotsWithPlants = 0
local readyPlants = 0
for _, plot in pairs(plots) do
local plant = plot:FindFirstChild("Plant")
if plant then
plotsWithPlants = plotsWithPlants + 1
if IsPlantReady(plant) then
readyPlants = readyPlants + 1
end
end
end
StatusLabel.Text = string.format(
"Status: %s\nPlots: %d\nWith Plants: %d\nReady: %d\nSelected: %s\nFarm: %s | Sell: %s",
_G.SimpleGaGUILoaded and "Running" or "Stopped",
#plots,
plotsWithPlants,
readyPlants,
Settings.SelectedPlant,
Settings.AutoFarm and "ON" or "OFF",
Settings.AutoSell and "ON" or "OFF"
)
wait(2)
end
end)
end
-- Initialize
wait(2) -- รอให้เกมโหลดเสร็จ
DebugPrint("กำลังเริ่มต้น Simple GaG UI v2...")
FindGameEvents()
CreateUI()
Notify("Simple GaG UI v2", "โหลดเสร็จเรียบร้อย! 🌱")
DebugPrint("Simple GaG UI v2 พร้อมใช้งาน!")
return {
Settings = Settings,
StartAutoFarm = StartAutoFarm,
StopAutoFarm = StopAutoFarm,
StartAutoSell = StartAutoSell,
StopAutoSell = StopAutoSell
}