-- Simple GaG Auto Farm (Fixed Version) -- ปรับจาก AutoFarm.lua ให้ใช้ UI แบบ Native print("🌱 Loading Simple GaG Auto Farm (Fixed)...") -- Services local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local RunService = game:GetService("RunService") local LocalPlayer = Players.LocalPlayer -- ตรวจสอบว่ามี PlayerGui local PlayerGui = LocalPlayer:WaitForChild("PlayerGui") -- ตรวจสอบ leaderstats local Leaderstats = LocalPlayer:WaitForChild("leaderstats") local Backpack = LocalPlayer:WaitForChild("Backpack") print("✅ Services loaded") -- ป้องกันการรันซ้ำ if _G.SimpleGaGFarmLoaded then print("⚠️ UI already loaded, removing old one...") if _G.SimpleGaGFarmUI then _G.SimpleGaGFarmUI:Destroy() end end _G.SimpleGaGFarmLoaded = true -- ตรวจสอบ Game Objects local GameEvents = ReplicatedStorage:WaitForChild("GameEvents") local Farms = workspace:WaitForChild("Farm") print("✅ Game objects found") -- Settings local Settings = { AutoPlant = false, AutoHarvest = false, AutoSell = false, SelectedSeed = "Carrot", SellThreshold = 15, PlantRandom = false, HarvestAll = true -- เก็บทุกอย่าง } -- Functions from AutoFarm.lua local function GetFarmOwner(Farm) local Important = Farm:FindFirstChild("Important") if not Important then return nil end local Data = Important:FindFirstChild("Data") if not Data then return nil end local Owner = Data:FindFirstChild("Owner") if not Owner then return nil end return Owner.Value end local function GetFarm(PlayerName) local AllFarms = Farms:GetChildren() for _, Farm in pairs(AllFarms) do local Owner = GetFarmOwner(Farm) if Owner == PlayerName then return Farm end end return nil end -- หาฟาร์มของผู้เล่น local MyFarm = GetFarm(LocalPlayer.Name) if not MyFarm then warn("❌ Cannot find player's farm!") game:GetService("StarterGui"):SetCore("SendNotification", { Title = "GaG Auto Farm", Text = "Cannot find your farm!", Duration = 5 }) return end print("✅ Found player farm: " .. MyFarm.Name) local MyImportant = MyFarm:FindFirstChild("Important") if not MyImportant then warn("❌ Farm Important folder not found!") return end local PlantLocations = MyImportant:FindFirstChild("Plant_Locations") local PlantsPhysical = MyImportant:FindFirstChild("Plants_Physical") if not PlantLocations or not PlantsPhysical then warn("❌ Farm locations not found!") return end print("✅ Farm components loaded") -- Helper Functions local function GetArea(Base) local Center = Base:GetPivot() local Size = Base.Size local X1 = math.ceil(Center.X - (Size.X/2)) local Z1 = math.ceil(Center.Z - (Size.Z/2)) local X2 = math.floor(Center.X + (Size.X/2)) local Z2 = math.floor(Center.Z + (Size.Z/2)) return X1, Z1, X2, Z2 end local Dirt = PlantLocations:FindFirstChildOfClass("Part") if not Dirt then warn("❌ No dirt found in farm!") return end local X1, Z1, X2, Z2 = GetArea(Dirt) print("✅ Farm area: " .. X1 .. "," .. Z1 .. " to " .. X2 .. "," .. Z2) local function Plant(Position, Seed) local PlantEvent = GameEvents:FindFirstChild("Plant_RE") if PlantEvent then PlantEvent:FireServer(Position, Seed) print("🌱 Planted " .. Seed .. " at " .. tostring(Position)) wait(0.3) return true end return false end local function GetOwnedSeeds() local Seeds = {} local Character = LocalPlayer.Character local function CollectFromParent(Parent) for _, Tool in pairs(Parent:GetChildren()) do if Tool:IsA("Tool") then local PlantName = Tool:FindFirstChild("Plant_Name") local Count = Tool:FindFirstChild("Numbers") if PlantName and Count then Seeds[PlantName.Value] = { Count = Count.Value, Tool = Tool } end end end end CollectFromParent(Backpack) if Character then CollectFromParent(Character) end return Seeds end local function GetHarvestablePlants() local Plants = {} local function CollectHarvestable(Parent) for _, Plant in pairs(Parent:GetChildren()) do -- Check for fruits folder local Fruits = Plant:FindFirstChild("Fruits") if Fruits then CollectHarvestable(Fruits) end -- Check for proximity prompt (เร็วขึ้น) local Prompt = Plant:FindFirstChild("ProximityPrompt", true) if Prompt and Prompt.Enabled then table.insert(Plants, Plant) end end end -- เก็บจากฟาร์มของผู้เล่นก่อน (เร็วที่สุด) CollectHarvestable(PlantsPhysical) -- เก็บจากฟาร์มคนอื่นด้วย (ถ้าเปิด HarvestAll) แบบ parallel if Settings.HarvestAll then local AllFarms = Farms:GetChildren() -- ใช้ spawn เพื่อค้นหาแบบ parallel for _, Farm in pairs(AllFarms) do if Farm ~= MyFarm then -- ไม่ใช่ฟาร์มตัวเอง spawn(function() local OtherPlantsPhysical = Farm:FindFirstChild("Important") if OtherPlantsPhysical then OtherPlantsPhysical = OtherPlantsPhysical:FindFirstChild("Plants_Physical") if OtherPlantsPhysical then CollectHarvestable(OtherPlantsPhysical) end end end) end end -- รอให้ค้นหาเสร็จ (เล็กน้อย) wait(0.1) end return Plants end local function HarvestPlant(Plant) local Prompt = Plant:FindFirstChild("ProximityPrompt", true) if Prompt and Prompt.Enabled then -- เก็บแบบเร็วไม่มี delay fireproximityprompt(Prompt) return true end return false end local function GetInvCrops() local Crops = {} local Character = LocalPlayer.Character local function CollectFromParent(Parent) for _, Tool in pairs(Parent:GetChildren()) do if Tool:IsA("Tool") then local ItemString = Tool:FindFirstChild("Item_String") if ItemString then table.insert(Crops, Tool) end end end end CollectFromParent(Backpack) if Character then CollectFromParent(Character) end return Crops end local IsSelling = false local function SellInventory() if IsSelling then return end IsSelling = true local Character = LocalPlayer.Character if not Character then IsSelling = false return end local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart") if not HumanoidRootPart then IsSelling = false return end local Previous = HumanoidRootPart.CFrame local ShecklesCount = Leaderstats:FindFirstChild("Sheckles") -- Teleport to sell area HumanoidRootPart.CFrame = CFrame.new(62, 4, -26) wait(0.5) if ShecklesCount then local PreviousSheckles = ShecklesCount.Value -- Try to sell local SellEvent = GameEvents:FindFirstChild("Sell_Inventory") if SellEvent then local attempts = 0 while attempts < 10 do if ShecklesCount.Value ~= PreviousSheckles then break end SellEvent:FireServer() wait(0.2) attempts = attempts + 1 end print("💰 ขายได้เงิน " .. (ShecklesCount.Value - PreviousSheckles) .. " sheckles") end end -- Return to previous position HumanoidRootPart.CFrame = Previous wait(0.2) IsSelling = false end -- Auto Functions local function AutoPlantLoop() if not Settings.AutoPlant then return end local OwnedSeeds = GetOwnedSeeds() local SeedData = OwnedSeeds[Settings.SelectedSeed] if not SeedData or SeedData.Count <= 0 then return end local Count = SeedData.Count local Tool = SeedData.Tool -- Equip the tool local Character = LocalPlayer.Character if Character and Tool.Parent == Backpack then local Humanoid = Character:FindFirstChild("Humanoid") if Humanoid then Humanoid:EquipTool(Tool) wait(0.5) end end local Planted = 0 if Settings.PlantRandom then -- Plant at random points local FarmLands = PlantLocations:GetChildren() for i = 1, math.min(Count, 10) do if not Settings.AutoPlant then break end local FarmLand = FarmLands[math.random(1, #FarmLands)] local LX1, LZ1, LX2, LZ2 = GetArea(FarmLand) local X = math.random(LX1, LX2) local Z = math.random(LZ1, LZ2) local Point = Vector3.new(X, 4, Z) if Plant(Point, Settings.SelectedSeed) then Planted = Planted + 1 end end else -- Plant in grid pattern for X = X1, X2, 2 do for Z = Z1, Z2, 2 do if Planted >= math.min(Count, 20) or not Settings.AutoPlant then break end local Point = Vector3.new(X, 0.13, Z) if Plant(Point, Settings.SelectedSeed) then Planted = Planted + 1 wait(0.1) end end if Planted >= math.min(Count, 20) or not Settings.AutoPlant then break end end end if Planted > 0 then print("🌱 ปลูก " .. Planted .. " เมล็ด " .. Settings.SelectedSeed) end end local function AutoHarvestLoop() if not Settings.AutoHarvest then return end local Plants = GetHarvestablePlants() if #Plants == 0 then return end local Harvested = 0 -- เก็บแบบ ultra fast - ทั้งหมดพร้อมกัน for _, Plant in pairs(Plants) do if not Settings.AutoHarvest then break end spawn(function() if HarvestPlant(Plant) then Harvested = Harvested + 1 end end) end -- รอให้เก็บเสร็จหมด (เล็กน้อย) wait(0.1) if Harvested > 0 then print("🚜 เก็บเกี่ยว " .. Harvested .. " ต้น") end end local function AutoSellLoop() if not Settings.AutoSell then return end local Crops = GetInvCrops() if #Crops < Settings.SellThreshold then return end print("💰 ขาย " .. #Crops .. " ผลผลิต (เกณฑ์: " .. Settings.SellThreshold .. ")") SellInventory() end -- Create UI local function CreateUI() print("🎨 Creating UI...") -- Remove old UI local oldUI = PlayerGui:FindFirstChild("SimpleGaGFarmUI") if oldUI then oldUI:Destroy() end -- ScreenGui local ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = "SimpleGaGFarmUI" ScreenGui.Parent = PlayerGui ScreenGui.ResetOnSpawn = false ScreenGui.IgnoreGuiInset = true _G.SimpleGaGFarmUI = ScreenGui -- Main Frame local MainFrame = Instance.new("Frame") MainFrame.Name = "MainFrame" MainFrame.Parent = ScreenGui MainFrame.BackgroundColor3 = Color3.fromRGB(26, 20, 8) MainFrame.BorderColor3 = Color3.fromRGB(69, 142, 40) MainFrame.BorderSizePixel = 2 MainFrame.Position = UDim2.new(0, 50, 0, 50) MainFrame.Size = UDim2.new(0, 300, 0, 400) MainFrame.Active = true MainFrame.Draggable = true -- Corner rounding local Corner = Instance.new("UICorner") Corner.CornerRadius = UDim.new(0, 8) Corner.Parent = MainFrame -- Title Bar local TitleBar = Instance.new("Frame") TitleBar.Name = "TitleBar" TitleBar.Parent = MainFrame TitleBar.BackgroundColor3 = Color3.fromRGB(45, 95, 25) TitleBar.BorderSizePixel = 0 TitleBar.Size = UDim2.new(1, 0, 0, 35) local TitleCorner = Instance.new("UICorner") TitleCorner.CornerRadius = UDim.new(0, 8) TitleCorner.Parent = TitleBar local Title = Instance.new("TextLabel") Title.Parent = TitleBar Title.BackgroundTransparency = 1 Title.Position = UDim2.new(0, 15, 0, 0) Title.Size = UDim2.new(1, -50, 1, 0) Title.Font = Enum.Font.SourceSansBold Title.Text = "🌱 ระบบฟาร์มอัตโนมัติ GaG" Title.TextColor3 = Color3.fromRGB(255, 255, 255) Title.TextSize = 16 Title.TextXAlignment = Enum.TextXAlignment.Left -- Close Button local CloseButton = Instance.new("TextButton") CloseButton.Parent = TitleBar CloseButton.BackgroundColor3 = Color3.fromRGB(255, 70, 70) CloseButton.BorderSizePixel = 0 CloseButton.Position = UDim2.new(1, -30, 0, 5) CloseButton.Size = UDim2.new(0, 25, 0, 25) CloseButton.Font = Enum.Font.SourceSansBold CloseButton.Text = "×" CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255) CloseButton.TextSize = 18 local CloseCorner = Instance.new("UICorner") CloseCorner.CornerRadius = UDim.new(0, 4) CloseCorner.Parent = CloseButton -- Content Frame local ContentFrame = Instance.new("Frame") ContentFrame.Parent = MainFrame ContentFrame.BackgroundTransparency = 1 ContentFrame.Position = UDim2.new(0, 15, 0, 45) ContentFrame.Size = UDim2.new(1, -30, 1, -60) local function CreateToggleButton(parent, text, position, callback) local ToggleFrame = Instance.new("Frame") ToggleFrame.Parent = parent ToggleFrame.BackgroundColor3 = Color3.fromRGB(45, 95, 25) ToggleFrame.BorderSizePixel = 0 ToggleFrame.Position = position ToggleFrame.Size = UDim2.new(1, 0, 0, 35) local FrameCorner = Instance.new("UICorner") FrameCorner.CornerRadius = UDim.new(0, 6) FrameCorner.Parent = ToggleFrame local Label = Instance.new("TextLabel") Label.Parent = ToggleFrame Label.BackgroundTransparency = 1 Label.Position = UDim2.new(0, 10, 0, 0) Label.Size = UDim2.new(1, -70, 1, 0) Label.Font = Enum.Font.SourceSans Label.Text = text Label.TextColor3 = Color3.fromRGB(255, 255, 255) Label.TextSize = 14 Label.TextXAlignment = Enum.TextXAlignment.Left local Toggle = Instance.new("TextButton") Toggle.Parent = ToggleFrame Toggle.BackgroundColor3 = Color3.fromRGB(255, 80, 80) Toggle.BorderSizePixel = 0 Toggle.Position = UDim2.new(1, -55, 0, 5) Toggle.Size = UDim2.new(0, 50, 0, 25) Toggle.Font = Enum.Font.SourceSansBold Toggle.Text = "OFF" Toggle.TextColor3 = Color3.fromRGB(255, 255, 255) Toggle.TextSize = 12 local ToggleCorner = Instance.new("UICorner") ToggleCorner.CornerRadius = UDim.new(0, 4) ToggleCorner.Parent = Toggle local isOn = false Toggle.MouseButton1Click:Connect(function() isOn = not isOn Toggle.Text = isOn and "ON" or "OFF" Toggle.BackgroundColor3 = isOn and Color3.fromRGB(80, 255, 80) or Color3.fromRGB(255, 80, 80) if callback then callback(isOn) end end) return Toggle end -- Auto Plant Toggle local PlantToggle = CreateToggleButton(ContentFrame, "🌱 ปลูกอัตโนมัติ", UDim2.new(0, 0, 0, 0), function(value) Settings.AutoPlant = value print("🌱 ปลูกอัตโนมัติ: " .. (value and "เปิด" or "ปิด")) end) -- Auto Harvest Toggle local HarvestToggle = CreateToggleButton(ContentFrame, "🚜 เก็บเกี่ยวอัตโนมัติ", UDim2.new(0, 0, 0, 45), function(value) Settings.AutoHarvest = value print("🚜 เก็บเกี่ยวอัตโนมัติ: " .. (value and "เปิด" or "ปิด")) end) -- Auto Sell Toggle local SellToggle = CreateToggleButton(ContentFrame, "💰 ขายอัตโนมัติ", UDim2.new(0, 0, 0, 90), function(value) Settings.AutoSell = value print("💰 ขายอัตโนมัติ: " .. (value and "เปิด" or "ปิด")) end) -- Harvest All Toggle local HarvestAllToggle = CreateToggleButton(ContentFrame, "🌍 เก็บทุกฟาร์ม", UDim2.new(0, 0, 0, 135), function(value) Settings.HarvestAll = value print("🌍 เก็บทุกฟาร์ม: " .. (value and "เปิด" or "ปิด")) end) -- Random Plant Toggle local RandomToggle = CreateToggleButton(ContentFrame, "🎲 ปลูกสุ่ม", UDim2.new(0, 0, 0, 180), function(value) Settings.PlantRandom = value print("🎲 ปลูกสุ่ม: " .. (value and "เปิด" or "ปิด")) end) -- Seed Selection local SeedFrame = Instance.new("Frame") SeedFrame.Parent = ContentFrame SeedFrame.BackgroundColor3 = Color3.fromRGB(45, 95, 25) SeedFrame.BorderSizePixel = 0 SeedFrame.Position = UDim2.new(0, 0, 0, 225) SeedFrame.Size = UDim2.new(1, 0, 0, 35) local SeedCorner = Instance.new("UICorner") SeedCorner.CornerRadius = UDim.new(0, 6) SeedCorner.Parent = SeedFrame local SeedLabel = Instance.new("TextLabel") SeedLabel.Parent = SeedFrame SeedLabel.BackgroundTransparency = 1 SeedLabel.Position = UDim2.new(0, 10, 0, 0) SeedLabel.Size = UDim2.new(1, -20, 1, 0) SeedLabel.Font = Enum.Font.SourceSans SeedLabel.Text = "🌱 เมล็ดพันธุ์: " .. Settings.SelectedSeed SeedLabel.TextColor3 = Color3.fromRGB(200, 255, 200) SeedLabel.TextSize = 12 SeedLabel.TextXAlignment = Enum.TextXAlignment.Left -- Status Display local StatusFrame = Instance.new("Frame") StatusFrame.Parent = ContentFrame StatusFrame.BackgroundColor3 = Color3.fromRGB(30, 25, 15) StatusFrame.BorderSizePixel = 0 StatusFrame.Position = UDim2.new(0, 0, 0, 270) StatusFrame.Size = UDim2.new(1, 0, 1, -280) local StatusCorner = Instance.new("UICorner") StatusCorner.CornerRadius = UDim.new(0, 6) StatusCorner.Parent = StatusFrame local StatusLabel = Instance.new("TextLabel") StatusLabel.Parent = StatusFrame StatusLabel.BackgroundTransparency = 1 StatusLabel.Position = UDim2.new(0, 10, 0, 10) StatusLabel.Size = UDim2.new(1, -20, 1, -20) StatusLabel.Font = Enum.Font.SourceSans StatusLabel.Text = "สถานะ: พร้อมใช้งาน" StatusLabel.TextColor3 = Color3.fromRGB(200, 255, 200) StatusLabel.TextSize = 11 StatusLabel.TextYAlignment = Enum.TextYAlignment.Top StatusLabel.TextXAlignment = Enum.TextXAlignment.Left StatusLabel.TextWrapped = true -- Set default HarvestAll to ON HarvestAllToggle.Text = "ON" HarvestAllToggle.BackgroundColor3 = Color3.fromRGB(80, 255, 80) -- Event Handlers CloseButton.MouseButton1Click:Connect(function() Settings.AutoPlant = false Settings.AutoHarvest = false Settings.AutoSell = false Settings.HarvestAll = false ScreenGui:Destroy() _G.SimpleGaGFarmLoaded = false _G.SimpleGaGFarmUI = nil print("🌱 ปิดระบบฟาร์มอัตโนมัติ") end) -- Update status spawn(function() while ScreenGui.Parent do local OwnedSeeds = GetOwnedSeeds() local Crops = GetInvCrops() local Plants = GetHarvestablePlants() local seedCount = OwnedSeeds[Settings.SelectedSeed] and OwnedSeeds[Settings.SelectedSeed].Count or 0 StatusLabel.Text = string.format( "📊 สถานะปัจจุบัน:\n\n🌱 เมล็ด: %d\n🥕 ผลผลิต: %d / %d\n🚜 พืชที่เก็บได้: %d\n⚡ โหมด: ULTRA FAST\n\n⚙️ ระบบที่เปิด:\n ปลูก: %s\n เก็บ: %s\n ขาย: %s\n เก็บทุกฟาร์ม: %s", seedCount, #Crops, Settings.SellThreshold, #Plants, Settings.AutoPlant and "เปิด" or "ปิด", Settings.AutoHarvest and "เปิด" or "ปิด", Settings.AutoSell and "เปิด" or "ปิด", Settings.HarvestAll and "เปิด" or "ปิด" ) wait(1) -- อัปเดตสถานะเร็วขึ้น end end) print("✅ UI created successfully!") return ScreenGui end -- Main Loops local function StartLoops() print("🔄 Starting main loops...") -- Auto Plant Loop spawn(function() while _G.SimpleGaGFarmLoaded do if Settings.AutoPlant then pcall(AutoPlantLoop) end wait(8) -- Plant every 8 seconds end end) -- Auto Harvest Loop (เร็วขึ้น) spawn(function() while _G.SimpleGaGFarmLoaded do if Settings.AutoHarvest then pcall(AutoHarvestLoop) end wait(0.5) -- Harvest every 0.5 seconds สำหรับความเร็ว end end) -- Auto Sell Loop spawn(function() while _G.SimpleGaGFarmLoaded do if Settings.AutoSell then pcall(AutoSellLoop) end wait(5) -- Check sell every 5 seconds end end) print("✅ All loops started") end -- Initialize Everything print("🚀 Initializing Simple GaG Auto Farm...") -- Wait a bit for everything to load wait(1) -- Create UI CreateUI() -- Start loops StartLoops() -- Success notification game:GetService("StarterGui"):SetCore("SendNotification", { Title = "ระบบฟาร์มอัตโนมัติ GaG", Text = "โหลดสำเร็จ! 🌱\nฟาร์ม: " .. MyFarm.Name, Duration = 5 }) print("✅ โหลดระบบฟาร์มอัตโนมัติ GaG สำเร็จ!") print("🌱 ฟาร์ม: " .. MyFarm.Name) print("📍 พื้นที่: " .. X1 .. "," .. Z1 .. " ถึง " .. X2 .. "," .. Z2) return { Settings = Settings, UI = _G.SimpleGaGFarmUI, MyFarm = MyFarm }