-- Simple GaG Auto Farm (Based on working AutoFarm.lua) -- ปรับจากไฟล์ที่ทำงานได้จริงแล้ว print("🌱 Loading Simple GaG Auto Farm...") -- Services local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local RunService = game:GetService("RunService") local LocalPlayer = Players.LocalPlayer local PlayerGui = LocalPlayer.PlayerGui -- ป้องกันการรันซ้ำ if _G.SimpleAutoFarmLoaded then print("⚠️ Simple Auto Farm already loaded!") if _G.SimpleAutoFarmUI then _G.SimpleAutoFarmUI:Destroy() end end _G.SimpleAutoFarmLoaded = true -- Settings local Settings = { AutoPlant = false, AutoHarvest = false, AutoSell = false, AutoBuy = false, SelectedSeed = "Carrot", SellThreshold = 15, PlantRandom = false } -- Game Objects (From AutoFarm.lua) local GameEvents = ReplicatedStorage.GameEvents local Farms = workspace.Farm -- Get player's farm local function GetFarmOwner(Farm) local Important = Farm.Important local Data = Important.Data local Owner = Data.Owner 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!") return end local MyImportant = MyFarm.Important local PlantLocations = MyImportant.Plant_Locations local PlantsPhysical = MyImportant.Plants_Physical local Dirt = PlantLocations:FindFirstChildOfClass("Part") -- Helper Functions (From AutoFarm.lua) 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 X1, Z1, X2, Z2 = GetArea(Dirt) local function GetRandomFarmPoint() local FarmLands = PlantLocations:GetChildren() local FarmLand = FarmLands[math.random(1, #FarmLands)] local X1, Z1, X2, Z2 = GetArea(FarmLand) local X = math.random(X1, X2) local Z = math.random(Z1, Z2) return Vector3.new(X, 4, Z) end local function Plant(Position, Seed) GameEvents.Plant_RE:FireServer(Position, Seed) wait(0.3) end local function HarvestPlant(Plant) local Prompt = Plant:FindFirstChild("ProximityPrompt", true) if not Prompt then return end fireproximityprompt(Prompt) end local function CanHarvest(Plant) local Prompt = Plant:FindFirstChild("ProximityPrompt", true) if not Prompt then return false end if not Prompt.Enabled then return false return true end local function GetHarvestablePlants() local Plants = {} local function CollectHarvestable(Parent) for _, Plant in pairs(Parent:GetChildren()) do -- Check for fruits local Fruits = Plant:FindFirstChild("Fruits") if Fruits then CollectHarvestable(Fruits) end -- Check if can harvest if CanHarvest(Plant) then table.insert(Plants, Plant) end end end CollectHarvestable(PlantsPhysical) return Plants end local function GetOwnedSeeds() local Seeds = {} local Character = LocalPlayer.Character local Backpack = LocalPlayer.Backpack local function CollectFromParent(Parent) for _, Tool in pairs(Parent:GetChildren()) do 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 CollectFromParent(Backpack) if Character then CollectFromParent(Character) end return Seeds end local function GetInvCrops() local Crops = {} local Character = LocalPlayer.Character local Backpack = LocalPlayer.Backpack local function CollectFromParent(Parent) for _, Tool in pairs(Parent:GetChildren()) do local ItemString = Tool:FindFirstChild("Item_String") if ItemString then table.insert(Crops, Tool) 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 Previous = Character:GetPivot() local Leaderstats = LocalPlayer.leaderstats local ShecklesCount = Leaderstats and Leaderstats:FindFirstChild("Sheckles") if ShecklesCount then local PreviousSheckles = ShecklesCount.Value -- Teleport to sell area Character:PivotTo(CFrame.new(62, 4, -26)) -- Keep trying to sell until money changes local attempts = 0 while attempts < 20 do if ShecklesCount.Value ~= PreviousSheckles then break end GameEvents.Sell_Inventory:FireServer() wait(0.1) attempts = attempts + 1 end -- Return to previous position Character:PivotTo(Previous) else -- Just fire the sell event if no leaderstats GameEvents.Sell_Inventory:FireServer() end wait(0.2) IsSelling = false end local function BuySeed(Seed) GameEvents.BuySeedStock:FireServer(Seed) end local function EquipTool(Tool) local Character = LocalPlayer.Character if not Character then return end local Humanoid = Character:FindFirstChild("Humanoid") if Tool.Parent == LocalPlayer.Backpack and Humanoid then Humanoid:EquipTool(Tool) end 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 print("🌱 No seeds to plant: " .. Settings.SelectedSeed) return end local Count = SeedData.Count local Tool = SeedData.Tool print("🌱 Planting " .. Count .. "x " .. Settings.SelectedSeed) -- Equip the tool EquipTool(Tool) local Planted = 0 if Settings.PlantRandom then -- Plant at random points for i = 1, Count do if not Settings.AutoPlant then break end local Point = GetRandomFarmPoint() Plant(Point, Settings.SelectedSeed) Planted = Planted + 1 end else -- Plant in grid pattern for X = X1, X2 do for Z = Z1, Z2 do if Planted >= Count or not Settings.AutoPlant then break end local Point = Vector3.new(X, 0.13, Z) Plant(Point, Settings.SelectedSeed) Planted = Planted + 1 end if Planted >= Count or not Settings.AutoPlant then break end end end print("🌱 Planted " .. Planted .. " seeds") end local function AutoHarvestLoop() if not Settings.AutoHarvest then return end local Plants = GetHarvestablePlants() if #Plants == 0 then return end print("🚜 Harvesting " .. #Plants .. " plants") for _, Plant in pairs(Plants) do if not Settings.AutoHarvest then break end HarvestPlant(Plant) wait(0.1) end end local function AutoSellLoop() if not Settings.AutoSell then return end local Crops = GetInvCrops() if #Crops < Settings.SellThreshold then return end print("💰 Selling " .. #Crops .. " crops") SellInventory() end local function AutoBuyLoop() if not Settings.AutoBuy then return end local OwnedSeeds = GetOwnedSeeds() local SeedData = OwnedSeeds[Settings.SelectedSeed] if SeedData and SeedData.Count > 0 then return end print("🛒 Buying seeds: " .. Settings.SelectedSeed) -- Buy multiple seeds for i = 1, 10 do BuySeed(Settings.SelectedSeed) wait(0.1) end end -- Create Simple UI local function CreateSimpleUI() -- Remove old UI local oldUI = PlayerGui:FindFirstChild("SimpleAutoFarmUI") if oldUI then oldUI:Destroy() end -- ScreenGui local ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = "SimpleAutoFarmUI" ScreenGui.Parent = PlayerGui ScreenGui.ResetOnSpawn = false _G.SimpleAutoFarmUI = ScreenGui -- Main Frame local MainFrame = Instance.new("Frame") MainFrame.Name = "MainFrame" MainFrame.Parent = ScreenGui MainFrame.BackgroundColor3 = Color3.fromRGB(26, 20, 8) -- Brown theme MainFrame.BorderColor3 = Color3.fromRGB(69, 142, 40) -- Green border MainFrame.BorderSizePixel = 2 MainFrame.Position = UDim2.new(0, 50, 0, 50) MainFrame.Size = UDim2.new(0, 320, 0, 450) MainFrame.Active = true MainFrame.Draggable = true -- Title Bar local TitleBar = Instance.new("Frame") TitleBar.Name = "TitleBar" TitleBar.Parent = MainFrame TitleBar.BackgroundColor3 = Color3.fromRGB(45, 95, 25) -- Dark green TitleBar.BorderSizePixel = 0 TitleBar.Size = UDim2.new(1, 0, 0, 30) local Title = Instance.new("TextLabel") Title.Parent = TitleBar Title.BackgroundTransparency = 1 Title.Position = UDim2.new(0, 10, 0, 0) Title.Size = UDim2.new(1, -40, 1, 0) Title.Font = Enum.Font.SourceSansBold Title.Text = "🌱 Simple GaG Auto Farm" Title.TextColor3 = Color3.fromRGB(255, 255, 255) Title.TextSize = 14 Title.TextXAlignment = Enum.TextXAlignment.Left -- Close Button local CloseButton = Instance.new("TextButton") CloseButton.Parent = TitleBar CloseButton.BackgroundColor3 = Color3.fromRGB(255, 60, 60) CloseButton.BorderSizePixel = 0 CloseButton.Position = UDim2.new(1, -30, 0, 0) CloseButton.Size = UDim2.new(0, 30, 0, 30) CloseButton.Font = Enum.Font.SourceSansBold CloseButton.Text = "X" CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255) CloseButton.TextSize = 14 -- Content Frame local ContentFrame = Instance.new("ScrollingFrame") ContentFrame.Parent = MainFrame ContentFrame.BackgroundTransparency = 1 ContentFrame.Position = UDim2.new(0, 10, 0, 40) ContentFrame.Size = UDim2.new(1, -20, 1, -50) ContentFrame.CanvasSize = UDim2.new(0, 0, 0, 500) ContentFrame.ScrollBarThickness = 8 local function CreateSection(name, yPos) local Section = Instance.new("Frame") Section.Parent = ContentFrame Section.BackgroundColor3 = Color3.fromRGB(45, 95, 25) Section.BorderColor3 = Color3.fromRGB(69, 142, 40) Section.BorderSizePixel = 1 Section.Position = UDim2.new(0, 0, 0, yPos) Section.Size = UDim2.new(1, -10, 0, 100) local SectionTitle = Instance.new("TextLabel") SectionTitle.Parent = Section SectionTitle.BackgroundColor3 = Color3.fromRGB(69, 142, 40) SectionTitle.BorderSizePixel = 0 SectionTitle.Size = UDim2.new(1, 0, 0, 25) SectionTitle.Font = Enum.Font.SourceSansBold SectionTitle.Text = name SectionTitle.TextColor3 = Color3.fromRGB(255, 255, 255) SectionTitle.TextSize = 12 return Section end local function CreateToggle(parent, text, yPos, callback) local ToggleFrame = Instance.new("Frame") ToggleFrame.Parent = parent ToggleFrame.BackgroundTransparency = 1 ToggleFrame.Position = UDim2.new(0, 10, 0, yPos) ToggleFrame.Size = UDim2.new(1, -20, 0, 25) local Label = Instance.new("TextLabel") Label.Parent = ToggleFrame Label.BackgroundTransparency = 1 Label.Position = UDim2.new(0, 0, 0, 0) Label.Size = UDim2.new(1, -60, 1, 0) Label.Font = Enum.Font.SourceSans Label.Text = text Label.TextColor3 = Color3.fromRGB(255, 255, 255) Label.TextSize = 11 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, -50, 0, 2) Toggle.Size = UDim2.new(0, 45, 0, 20) Toggle.Font = Enum.Font.SourceSansBold Toggle.Text = "OFF" Toggle.TextColor3 = Color3.fromRGB(255, 255, 255) Toggle.TextSize = 10 Toggle.MouseButton1Click:Connect(function() local newValue = Toggle.Text == "OFF" Toggle.Text = newValue and "ON" or "OFF" Toggle.BackgroundColor3 = newValue and Color3.fromRGB(80, 255, 80) or Color3.fromRGB(255, 80, 80) if callback then callback(newValue) end end) return Toggle end -- Auto Plant Section local PlantSection = CreateSection("🌱 Auto Plant", 0) local PlantToggle = CreateToggle(PlantSection, "Auto Plant", 30, function(value) Settings.AutoPlant = value print("Auto Plant: " .. (value and "ON" or "OFF")) end) local RandomToggle = CreateToggle(PlantSection, "Random Points", 55, function(value) Settings.PlantRandom = value print("Random Plant: " .. (value and "ON" or "OFF")) end) -- Seed Selection local SeedLabel = Instance.new("TextLabel") SeedLabel.Parent = PlantSection SeedLabel.BackgroundTransparency = 1 SeedLabel.Position = UDim2.new(0, 10, 0, 80) SeedLabel.Size = UDim2.new(1, -20, 0, 15) SeedLabel.Font = Enum.Font.SourceSans SeedLabel.Text = "Seed: " .. Settings.SelectedSeed SeedLabel.TextColor3 = Color3.fromRGB(200, 255, 200) SeedLabel.TextSize = 10 SeedLabel.TextXAlignment = Enum.TextXAlignment.Left -- Auto Harvest Section local HarvestSection = CreateSection("🚜 Auto Harvest", 110) local HarvestToggle = CreateToggle(HarvestSection, "Auto Harvest", 30, function(value) Settings.AutoHarvest = value print("Auto Harvest: " .. (value and "ON" or "OFF")) end) -- Auto Sell Section local SellSection = CreateSection("💰 Auto Sell", 220) local SellToggle = CreateToggle(SellSection, "Auto Sell", 30, function(value) Settings.AutoSell = value print("Auto Sell: " .. (value and "ON" or "OFF")) end) local ThresholdLabel = Instance.new("TextLabel") ThresholdLabel.Parent = SellSection ThresholdLabel.BackgroundTransparency = 1 ThresholdLabel.Position = UDim2.new(0, 10, 0, 55) ThresholdLabel.Size = UDim2.new(1, -20, 0, 15) ThresholdLabel.Font = Enum.Font.SourceSans ThresholdLabel.Text = "Sell at: " .. Settings.SellThreshold .. " crops" ThresholdLabel.TextColor3 = Color3.fromRGB(200, 255, 200) ThresholdLabel.TextSize = 10 ThresholdLabel.TextXAlignment = Enum.TextXAlignment.Left -- Auto Buy Section local BuySection = CreateSection("🛒 Auto Buy", 330) local BuyToggle = CreateToggle(BuySection, "Auto Buy Seeds", 30, function(value) Settings.AutoBuy = value print("Auto Buy: " .. (value and "ON" or "OFF")) end) -- Status Display local StatusLabel = Instance.new("TextLabel") StatusLabel.Parent = ContentFrame StatusLabel.BackgroundColor3 = Color3.fromRGB(26, 20, 8) StatusLabel.BorderColor3 = Color3.fromRGB(69, 142, 40) StatusLabel.BorderSizePixel = 1 StatusLabel.Position = UDim2.new(0, 0, 0, 440) StatusLabel.Size = UDim2.new(1, -10, 0, 50) StatusLabel.Font = Enum.Font.SourceSans StatusLabel.Text = "Status: Ready" StatusLabel.TextColor3 = Color3.fromRGB(200, 255, 200) StatusLabel.TextSize = 10 StatusLabel.TextYAlignment = Enum.TextYAlignment.Top -- Event Handlers CloseButton.MouseButton1Click:Connect(function() -- Stop all loops Settings.AutoPlant = false Settings.AutoHarvest = false Settings.AutoSell = false Settings.AutoBuy = false ScreenGui:Destroy() _G.SimpleAutoFarmLoaded = false _G.SimpleAutoFarmUI = nil print("🌱 Simple Auto Farm closed") 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( "Seeds: %d | Crops: %d | Ready: %d\nPlant: %s | Harvest: %s | Sell: %s", seedCount, #Crops, #Plants, Settings.AutoPlant and "ON" or "OFF", Settings.AutoHarvest and "ON" or "OFF", Settings.AutoSell and "ON" or "OFF" ) wait(2) end end) print("✅ Simple Auto Farm UI created successfully!") return ScreenGui end -- Main Loops local function StartAutoLoops() -- Auto Plant Loop spawn(function() while _G.SimpleAutoFarmLoaded do if Settings.AutoPlant then pcall(AutoPlantLoop) end wait(5) -- Check every 5 seconds end end) -- Auto Harvest Loop spawn(function() while _G.SimpleAutoFarmLoaded do if Settings.AutoHarvest then pcall(AutoHarvestLoop) end wait(1) -- Check every second end end) -- Auto Sell Loop spawn(function() while _G.SimpleAutoFarmLoaded do if Settings.AutoSell then pcall(AutoSellLoop) end wait(3) -- Check every 3 seconds end end) -- Auto Buy Loop spawn(function() while _G.SimpleAutoFarmLoaded do if Settings.AutoBuy then pcall(AutoBuyLoop) end wait(10) -- Check every 10 seconds end end) end -- Initialize print("🌱 Farm found: " .. MyFarm.Name) print("🌱 Farm area: " .. X1 .. "," .. Z1 .. " to " .. X2 .. "," .. Z2) CreateSimpleUI() StartAutoLoops() -- Notification game:GetService("StarterGui"):SetCore("SendNotification", { Title = "Simple GaG Auto Farm", Text = "Loaded successfully! 🌱", Duration = 3 }) print("✅ Simple GaG Auto Farm loaded successfully!") return { Settings = Settings, UI = _G.SimpleAutoFarmUI }