-- Ultimate GaG Auto Farm - Compact & Collapsible -- รวมทุกฟีเจอร์ไว้ที่เดียว ปรับได้หมด UI เล็กกะทัดรัด print("🌱 Loading Ultimate GaG Auto Farm (Compact)...") -- Services local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local TweenService = game:GetService("TweenService") local LocalPlayer = Players.LocalPlayer local PlayerGui = LocalPlayer:WaitForChild("PlayerGui") local Leaderstats = LocalPlayer:WaitForChild("leaderstats") local Backpack = LocalPlayer:WaitForChild("Backpack") print("✅ Services loaded") -- ป้องกันการรันซ้ำ if _G.UltimateGaGFarmLoaded then print("⚠️ Ultimate GaG Farm already loaded, removing old one...") if _G.UltimateGaGFarmUI then _G.UltimateGaGFarmUI:Destroy() end end _G.UltimateGaGFarmLoaded = true -- Game Objects local GameEvents = ReplicatedStorage:WaitForChild("GameEvents") local Farms = workspace:WaitForChild("Farm") print("✅ Game objects found") -- Compact Settings local Settings = { -- Auto Farm Settings AutoPlant = false, AutoHarvest = false, AutoSell = false, AutoBuy = false, -- Basic Settings SelectedSeed = "Carrot", HarvestAll = true, HarvestSpeed = "Ultra Fast", SellThreshold = 15, PlantRandom = false, -- UI Settings UICollapsed = false, SectionsCollapsed = { Plant = false, Harvest = false, Sell = false, Advanced = true } } -- Find Player's Farm 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 = "Ultimate GaG Farm", Text = "ไม่พบฟาร์มของคุณ!", Duration = 5 }) return end print("✅ Found player farm: " .. MyFarm.Name) local MyImportant = MyFarm:FindFirstChild("Important") local PlantLocations = MyImportant:FindFirstChild("Plant_Locations") local PlantsPhysical = MyImportant:FindFirstChild("Plants_Physical") -- 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") local X1, Z1, X2, Z2 = GetArea(Dirt) -- Plant Function local function Plant(Position, Seed) local PlantEvent = GameEvents:FindFirstChild("Plant_RE") if PlantEvent then PlantEvent:FireServer(Position, Seed) wait(0.3) return true end return false end -- Get Owned Seeds 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 -- Get Harvestable Plants local function GetHarvestablePlants() local Plants = {} local function CollectHarvestable(Parent) for _, Plant in pairs(Parent:GetChildren()) do local Fruits = Plant:FindFirstChild("Fruits") if Fruits then CollectHarvestable(Fruits) end local Prompt = Plant:FindFirstChild("ProximityPrompt", true) if Prompt and Prompt.Enabled then table.insert(Plants, Plant) end end end CollectHarvestable(PlantsPhysical) if Settings.HarvestAll then for _, Farm in pairs(Farms:GetChildren()) 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 -- Harvest Plant Function local function HarvestPlant(Plant) local Prompt = Plant:FindFirstChild("ProximityPrompt", true) if Prompt and Prompt.Enabled then fireproximityprompt(Prompt) return true end return false end -- Get Inventory Crops 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 -- Sell Inventory Function 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, 20) 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, 30) 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, 30) 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 if Settings.HarvestSpeed == "Instant" then -- เก็บทั้งหมดพร้อมกัน 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 else -- เก็บแบบปกติ for _, Plant in pairs(Plants) do if not Settings.AutoHarvest then break end if HarvestPlant(Plant) then Harvested = Harvested + 1 end if Settings.HarvestSpeed == "Fast" then wait(0.05) elseif Settings.HarvestSpeed == "Ultra Fast" then -- ไม่มี delay else wait(0.1) end end end 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 .. " ผลผลิต") SellInventory() end -- Create Smooth Compact UI local function CreateCompactUI() print("🎨 Creating Smooth Compact UI...") -- Remove old UI local oldUI = PlayerGui:FindFirstChild("UltimateGaGFarmUI") if oldUI then oldUI:Destroy() end -- ScreenGui local ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = "UltimateGaGFarmUI" ScreenGui.Parent = PlayerGui ScreenGui.ResetOnSpawn = false ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling _G.UltimateGaGFarmUI = ScreenGui -- Main Frame (ปรับขนาดให้เหมาะสม) local MainFrame = Instance.new("Frame") MainFrame.Name = "MainFrame" MainFrame.Parent = ScreenGui MainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 35) MainFrame.BorderSizePixel = 0 MainFrame.Position = UDim2.new(0, 50, 0, 50) MainFrame.Size = UDim2.new(0, 280, 0, Settings.UICollapsed and 40 or 350) MainFrame.Active = true MainFrame.Draggable = true MainFrame.ZIndex = 1 local Corner = Instance.new("UICorner") Corner.CornerRadius = UDim.new(0, 10) Corner.Parent = MainFrame local Stroke = Instance.new("UIStroke") Stroke.Parent = MainFrame Stroke.Color = Color3.fromRGB(70, 170, 255) Stroke.Thickness = 2 local Shadow = Instance.new("Frame") Shadow.Parent = ScreenGui Shadow.BackgroundColor3 = Color3.fromRGB(0, 0, 0) Shadow.BackgroundTransparency = 0.7 Shadow.BorderSizePixel = 0 Shadow.Position = UDim2.new(0, 52, 0, 52) Shadow.Size = MainFrame.Size Shadow.ZIndex = 0 local ShadowCorner = Instance.new("UICorner") ShadowCorner.CornerRadius = UDim.new(0, 10) ShadowCorner.Parent = Shadow -- Title Bar local TitleBar = Instance.new("Frame") TitleBar.Name = "TitleBar" TitleBar.Parent = MainFrame TitleBar.BackgroundColor3 = Color3.fromRGB(45, 130, 220) TitleBar.BorderSizePixel = 0 TitleBar.Size = UDim2.new(1, 0, 0, 35) TitleBar.ZIndex = 2 local TitleCorner = Instance.new("UICorner") TitleCorner.CornerRadius = UDim.new(0, 10) TitleCorner.Parent = TitleBar local TitleGradient = Instance.new("UIGradient") TitleGradient.Parent = TitleBar TitleGradient.Color = ColorSequence.new({ ColorSequenceKeypoint.new(0, Color3.fromRGB(45, 130, 220)), ColorSequenceKeypoint.new(1, Color3.fromRGB(25, 110, 200)) }) TitleGradient.Rotation = 90 local Title = Instance.new("TextLabel") Title.Parent = TitleBar Title.BackgroundTransparency = 1 Title.Position = UDim2.new(0, 15, 0, 0) Title.Size = UDim2.new(1, -80, 1, 0) Title.Font = Enum.Font.SourceSansBold Title.Text = "🌱 ระบบฟาร์มอัตโนมัติ" Title.TextColor3 = Color3.fromRGB(255, 255, 255) Title.TextSize = 13 Title.TextXAlignment = Enum.TextXAlignment.Left Title.ZIndex = 3 -- Collapse/Expand Button local CollapseButton = Instance.new("TextButton") CollapseButton.Parent = TitleBar CollapseButton.BackgroundColor3 = Color3.fromRGB(35, 110, 190) CollapseButton.BorderSizePixel = 0 CollapseButton.Position = UDim2.new(1, -65, 0, 5) CollapseButton.Size = UDim2.new(0, 25, 0, 25) CollapseButton.Font = Enum.Font.SourceSansBold CollapseButton.Text = Settings.UICollapsed and "▼" or "▲" CollapseButton.TextColor3 = Color3.fromRGB(255, 255, 255) CollapseButton.TextSize = 12 CollapseButton.ZIndex = 3 local CollapseCorner = Instance.new("UICorner") CollapseCorner.CornerRadius = UDim.new(0, 5) CollapseCorner.Parent = CollapseButton -- Close Button local CloseButton = Instance.new("TextButton") CloseButton.Parent = TitleBar CloseButton.BackgroundColor3 = Color3.fromRGB(220, 80, 80) CloseButton.BorderSizePixel = 0 CloseButton.Position = UDim2.new(1, -35, 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 = 16 CloseButton.ZIndex = 3 local CloseCorner = Instance.new("UICorner") CloseCorner.CornerRadius = UDim.new(0, 5) CloseCorner.Parent = CloseButton -- Content Frame with ScrollingFrame local ContentFrame = Instance.new("ScrollingFrame") ContentFrame.Parent = MainFrame ContentFrame.BackgroundTransparency = 1 ContentFrame.Position = UDim2.new(0, 10, 0, 45) ContentFrame.Size = UDim2.new(1, -20, 1, -55) ContentFrame.Visible = not Settings.UICollapsed ContentFrame.CanvasSize = UDim2.new(0, 0, 0, 0) ContentFrame.ScrollBarThickness = 5 ContentFrame.ScrollBarImageColor3 = Color3.fromRGB(70, 170, 255) ContentFrame.ScrollingDirection = Enum.ScrollingDirection.Y ContentFrame.ZIndex = 2 -- Auto-resize canvas local function UpdateCanvasSize() local totalHeight = 0 for _, child in pairs(ContentFrame:GetChildren()) do if child:IsA("GuiObject") and child.Visible then totalHeight = math.max(totalHeight, child.Position.Y.Offset + child.Size.Y.Offset + 10) end end ContentFrame.CanvasSize = UDim2.new(0, 0, 0, totalHeight) end -- Helper function สำหรับสร้าง section ที่ collapse ได้ (ปรับปรุงแล้ว) local function CreateCollapsibleSection(title, yPos, sectionKey, height) local Section = Instance.new("Frame") Section.Parent = ContentFrame Section.BackgroundColor3 = Color3.fromRGB(40, 40, 45) Section.BorderSizePixel = 0 Section.Position = UDim2.new(0, 0, 0, yPos) Section.Size = UDim2.new(1, -5, 0, Settings.SectionsCollapsed[sectionKey] and 30 or height) Section.ZIndex = 2 local SectionCorner = Instance.new("UICorner") SectionCorner.CornerRadius = UDim.new(0, 8) SectionCorner.Parent = Section local SectionStroke = Instance.new("UIStroke") SectionStroke.Parent = Section SectionStroke.Color = Color3.fromRGB(60, 60, 70) SectionStroke.Thickness = 1 -- Section Header local SectionHeader = Instance.new("TextButton") SectionHeader.Parent = Section SectionHeader.BackgroundColor3 = Color3.fromRGB(50, 140, 230) SectionHeader.BorderSizePixel = 0 SectionHeader.Size = UDim2.new(1, 0, 0, 28) SectionHeader.Font = Enum.Font.SourceSansBold SectionHeader.Text = (Settings.SectionsCollapsed[sectionKey] and "▶ " or "▼ ") .. title SectionHeader.TextColor3 = Color3.fromRGB(255, 255, 255) SectionHeader.TextSize = 12 SectionHeader.TextXAlignment = Enum.TextXAlignment.Center SectionHeader.ZIndex = 3 local HeaderCorner = Instance.new("UICorner") HeaderCorner.CornerRadius = UDim.new(0, 8) HeaderCorner.Parent = SectionHeader local HeaderGradient = Instance.new("UIGradient") HeaderGradient.Parent = SectionHeader HeaderGradient.Color = ColorSequence.new({ ColorSequenceKeypoint.new(0, Color3.fromRGB(50, 140, 230)), ColorSequenceKeypoint.new(1, Color3.fromRGB(30, 120, 210)) }) HeaderGradient.Rotation = 90 -- Section Content local SectionContent = Instance.new("Frame") SectionContent.Parent = Section SectionContent.BackgroundTransparency = 1 SectionContent.Position = UDim2.new(0, 8, 0, 35) SectionContent.Size = UDim2.new(1, -16, 1, -42) SectionContent.Visible = not Settings.SectionsCollapsed[sectionKey] SectionContent.ZIndex = 3 -- Smooth Collapse/Expand functionality SectionHeader.MouseButton1Click:Connect(function() Settings.SectionsCollapsed[sectionKey] = not Settings.SectionsCollapsed[sectionKey] local collapsed = Settings.SectionsCollapsed[sectionKey] SectionHeader.Text = (collapsed and "▶ " or "▼ ") .. title -- Smooth animation local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quart, Enum.EasingDirection.Out) local sizeTween = TweenService:Create(Section, tweenInfo, { Size = UDim2.new(1, -5, 0, collapsed and 30 or height) }) if collapsed then sizeTween:Play() wait(0.1) SectionContent.Visible = false else SectionContent.Visible = true sizeTween:Play() end -- Update canvas size after animation spawn(function() wait(0.5) UpdateCanvasSize() end) end) return Section, SectionContent end -- Helper function สำหรับสร้าง toggle ขนาดเล็ก (ปรับปรุงแล้ว) local function CreateSmallToggle(parent, text, yPos, callback, defaultState) local ToggleFrame = Instance.new("Frame") ToggleFrame.Parent = parent ToggleFrame.BackgroundTransparency = 1 ToggleFrame.Position = UDim2.new(0, 0, 0, yPos) ToggleFrame.Size = UDim2.new(1, 0, 0, 25) ToggleFrame.ZIndex = 3 local Label = Instance.new("TextLabel") Label.Parent = ToggleFrame Label.BackgroundTransparency = 1 Label.Position = UDim2.new(0, 5, 0, 0) Label.Size = UDim2.new(1, -65, 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 Label.ZIndex = 4 local Toggle = Instance.new("TextButton") Toggle.Parent = ToggleFrame Toggle.BackgroundColor3 = defaultState and Color3.fromRGB(50, 200, 100) or Color3.fromRGB(200, 100, 100) Toggle.BorderSizePixel = 0 Toggle.Position = UDim2.new(1, -55, 0, 3) Toggle.Size = UDim2.new(0, 50, 0, 19) Toggle.Font = Enum.Font.SourceSansBold Toggle.Text = defaultState and "เปิด" or "ปิด" Toggle.TextColor3 = Color3.fromRGB(255, 255, 255) Toggle.TextSize = 9 Toggle.ZIndex = 4 local ToggleCorner = Instance.new("UICorner") ToggleCorner.CornerRadius = UDim.new(0, 4) ToggleCorner.Parent = Toggle -- Hover effect Toggle.MouseEnter:Connect(function() TweenService:Create(Toggle, TweenInfo.new(0.2), { BackgroundColor3 = Toggle.BackgroundColor3:lerp(Color3.fromRGB(255, 255, 255), 0.1) }):Play() end) Toggle.MouseLeave:Connect(function() local targetColor = Toggle.Text == "เปิด" and Color3.fromRGB(50, 200, 100) or Color3.fromRGB(200, 100, 100) TweenService:Create(Toggle, TweenInfo.new(0.2), { BackgroundColor3 = targetColor }):Play() end) local isOn = defaultState or false Toggle.MouseButton1Click:Connect(function() isOn = not isOn Toggle.Text = isOn and "เปิด" or "ปิด" local targetColor = isOn and Color3.fromRGB(50, 200, 100) or Color3.fromRGB(200, 100, 100) TweenService:Create(Toggle, TweenInfo.new(0.3), { BackgroundColor3 = targetColor }):Play() if callback then callback(isOn) end end) return Toggle end -- Helper function สำหรับสร้าง dropdown ขนาดเล็ก (ปรับปรุงแล้ว) local function CreateSmallDropdown(parent, text, yPos, options, callback, defaultValue) local DropdownFrame = Instance.new("Frame") DropdownFrame.Parent = parent DropdownFrame.BackgroundTransparency = 1 DropdownFrame.Position = UDim2.new(0, 0, 0, yPos) DropdownFrame.Size = UDim2.new(1, 0, 0, 25) DropdownFrame.ZIndex = 3 local Label = Instance.new("TextLabel") Label.Parent = DropdownFrame Label.BackgroundTransparency = 1 Label.Position = UDim2.new(0, 5, 0, 0) Label.Size = UDim2.new(0.45, 0, 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 Label.ZIndex = 4 local DropdownButton = Instance.new("TextButton") DropdownButton.Parent = DropdownFrame DropdownButton.BackgroundColor3 = Color3.fromRGB(60, 60, 70) DropdownButton.BorderSizePixel = 0 DropdownButton.Position = UDim2.new(0.45, 5, 0, 3) DropdownButton.Size = UDim2.new(0.55, -10, 0, 19) DropdownButton.Font = Enum.Font.SourceSans DropdownButton.Text = defaultValue or options[1] or "เลือก" DropdownButton.TextColor3 = Color3.fromRGB(255, 255, 255) DropdownButton.TextSize = 9 DropdownButton.ZIndex = 4 local DropdownCorner = Instance.new("UICorner") DropdownCorner.CornerRadius = UDim.new(0, 4) DropdownCorner.Parent = DropdownButton -- Hover effect DropdownButton.MouseEnter:Connect(function() TweenService:Create(DropdownButton, TweenInfo.new(0.2), { BackgroundColor3 = Color3.fromRGB(80, 80, 90) }):Play() end) DropdownButton.MouseLeave:Connect(function() TweenService:Create(DropdownButton, TweenInfo.new(0.2), { BackgroundColor3 = Color3.fromRGB(60, 60, 70) }):Play() end) -- Simple cycling through options local currentIndex = 1 for i, option in ipairs(options) do if option == defaultValue then currentIndex = i break end end DropdownButton.MouseButton1Click:Connect(function() currentIndex = currentIndex + 1 if currentIndex > #options then currentIndex = 1 end local selectedValue = options[currentIndex] DropdownButton.Text = selectedValue -- Click animation TweenService:Create(DropdownButton, TweenInfo.new(0.1), { BackgroundColor3 = Color3.fromRGB(100, 100, 110) }):Play() wait(0.1) TweenService:Create(DropdownButton, TweenInfo.new(0.2), { BackgroundColor3 = Color3.fromRGB(60, 60, 70) }):Play() if callback then callback(selectedValue) end end) return DropdownButton end -- Quick Controls Section (ส่วนควบคุมหลัก) local QuickSection, QuickContent = CreateCollapsibleSection("⚡ ควบคุมหลัก", 0, "Plant", 95) CreateSmallToggle(QuickContent, "🌱 ปลูกอัตโนมัติ", 0, function(value) Settings.AutoPlant = value print("🌱 ปลูกอัตโนมัติ: " .. (value and "เปิด" or "ปิด")) end, Settings.AutoPlant) CreateSmallToggle(QuickContent, "🚜 เก็บเกี่ยวอัตโนมัติ", 30, function(value) Settings.AutoHarvest = value print("🚜 เก็บเกี่ยวอัตโนมัติ: " .. (value and "เปิด" or "ปิด")) end, Settings.AutoHarvest) CreateSmallToggle(QuickContent, "💰 ขายอัตโนมัติ", 60, function(value) Settings.AutoSell = value print("💰 ขายอัตโนมัติ: " .. (value and "เปิด" or "ปิด")) end, Settings.AutoSell) -- Harvest Options Section local HarvestSection, HarvestContent = CreateCollapsibleSection("🚜 ตัวเลือกการเก็บเกี่ยว", 105, "Harvest", 80) CreateSmallToggle(HarvestContent, "🌍 เก็บทุกฟาร์ม", 0, function(value) Settings.HarvestAll = value print("🌍 เก็บทุกฟาร์ม: " .. (value and "เปิด" or "ปิด")) end, Settings.HarvestAll) CreateSmallDropdown(HarvestContent, "⚡ ความเร็ว:", 30, {"ปกติ", "เร็ว", "เร็วมาก", "ทันที"}, function(value) local speedMap = { ["ปกติ"] = "Normal", ["เร็ว"] = "Fast", ["เร็วมาก"] = "Ultra Fast", ["ทันที"] = "Instant" } Settings.HarvestSpeed = speedMap[value] or "Ultra Fast" print("⚡ ความเร็วการเก็บ: " .. value) end, "เร็วมาก") -- Sell Options Section local SellSection, SellContent = CreateCollapsibleSection("💰 ตัวเลือกการขาย", 195, "Sell", 55) local SellLabel = Instance.new("TextLabel") SellLabel.Parent = SellContent SellLabel.BackgroundTransparency = 1 SellLabel.Position = UDim2.new(0, 5, 0, 5) SellLabel.Size = UDim2.new(1, -10, 0, 20) SellLabel.Font = Enum.Font.SourceSans SellLabel.Text = "💰 ขายเมื่อมี " .. Settings.SellThreshold .. " ชิ้น" SellLabel.TextColor3 = Color3.fromRGB(180, 255, 180) SellLabel.TextSize = 11 SellLabel.TextXAlignment = Enum.TextXAlignment.Left SellLabel.ZIndex = 4 -- Advanced Section (ยุบไว้) local AdvancedSection, AdvancedContent = CreateCollapsibleSection("⚙️ ขั้นสูง", 260, "Advanced", 95) CreateSmallToggle(AdvancedContent, "🛒 ซื้อเมล็ดอัตโนมัติ", 0, function(value) Settings.AutoBuy = value print("🛒 ซื้อเมล็ดอัตโนมัติ: " .. (value and "เปิด" or "ปิด")) end, Settings.AutoBuy) CreateSmallToggle(AdvancedContent, "🎲 ปลูกแบบสุ่ม", 30, function(value) Settings.PlantRandom = value print("🎲 ปลูกแบบสุ่ม: " .. (value and "เปิด" or "ปิด")) end, Settings.PlantRandom) local SeedLabel = Instance.new("TextLabel") SeedLabel.Parent = AdvancedContent SeedLabel.BackgroundTransparency = 1 SeedLabel.Position = UDim2.new(0, 5, 0, 60) SeedLabel.Size = UDim2.new(1, -10, 0, 20) SeedLabel.Font = Enum.Font.SourceSans SeedLabel.Text = "🌱 เมล็ดพันธุ์: " .. Settings.SelectedSeed SeedLabel.TextColor3 = Color3.fromRGB(180, 255, 180) SeedLabel.TextSize = 10 SeedLabel.TextXAlignment = Enum.TextXAlignment.Left SeedLabel.ZIndex = 4 -- Initial canvas size setup spawn(function() wait(0.1) UpdateCanvasSize() end) -- Collapse/Expand Main UI CollapseButton.MouseButton1Click:Connect(function() Settings.UICollapsed = not Settings.UICollapsed CollapseButton.Text = Settings.UICollapsed and "▼" or "▲" -- Smooth main UI collapse/expand local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quart, Enum.EasingDirection.Out) local sizeTween = TweenService:Create(MainFrame, tweenInfo, { Size = UDim2.new(0, 280, 0, Settings.UICollapsed and 40 or 350) }) local shadowTween = TweenService:Create(Shadow, tweenInfo, { Size = UDim2.new(0, 280, 0, Settings.UICollapsed and 40 or 350) }) if Settings.UICollapsed then sizeTween:Play() shadowTween:Play() wait(0.2) ContentFrame.Visible = false else ContentFrame.Visible = true sizeTween:Play() shadowTween:Play() spawn(function() wait(0.3) UpdateCanvasSize() end) end end) -- Close Button CloseButton.MouseButton1Click:Connect(function() Settings.AutoPlant = false Settings.AutoHarvest = false Settings.AutoSell = false Settings.AutoBuy = false ScreenGui:Destroy() _G.UltimateGaGFarmLoaded = false _G.UltimateGaGFarmUI = nil print("🌱 ปิดระบบฟาร์มอัตโนมัติ") end) -- Status Update (แสดงใน title) 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 Title.Text = string.format("🌱 ฟาร์มอัตโนมัติ | 🌱%d 🥕%d 🚜%d", seedCount, #Crops, #Plants) wait(2) end end) print("✅ Compact UI created!") return ScreenGui end -- Optimized Main Loops (เพื่อความ smooth) local function StartSmoothLoops() print("🔄 Starting smooth loops...") -- Auto Plant Loop (ปลูกทุก 10 วินาที) spawn(function() while _G.UltimateGaGFarmLoaded do if Settings.AutoPlant and not IsSelling then local success, err = pcall(AutoPlantLoop) if not success then print("⚠️ Plant error: " .. tostring(err)) end end wait(10) -- เพิ่มระยะห่างให้ smooth กว่า end end) -- Auto Harvest Loop (เก็บทุก 1 วินาที แต่ไม่ขัดจังหวะ) spawn(function() while _G.UltimateGaGFarmLoaded do if Settings.AutoHarvest and not IsSelling then local success, err = pcall(AutoHarvestLoop) if not success then print("⚠️ Harvest error: " .. tostring(err)) end end -- Dynamic wait based on speed setting local waitTime = 1 if Settings.HarvestSpeed == "Instant" then waitTime = 0.3 elseif Settings.HarvestSpeed == "Ultra Fast" then waitTime = 0.5 elseif Settings.HarvestSpeed == "Fast" then waitTime = 0.8 end wait(waitTime) end end) -- Auto Sell Loop (ขายทุก 7 วินาที) spawn(function() while _G.UltimateGaGFarmLoaded do if Settings.AutoSell then local success, err = pcall(AutoSellLoop) if not success then print("⚠️ Sell error: " .. tostring(err)) end end wait(7) -- เพิ่มเวลาให้การขายไม่ขัดจังหวะการทำงาน end end) print("✅ All smooth loops started") end -- Initialize print("🚀 Initializing Compact GaG Auto Farm...") -- Wait a bit for everything to load wait(1) -- Create UI CreateCompactUI() -- Start smooth loops StartSmoothLoops() -- Success notification game:GetService("StarterGui"):SetCore("SendNotification", { Title = "🌱 ระบบฟาร์มอัตโนมัติ", Text = "โหลดเรียบร้อย! UI แบบกะทัดรัด ✨", Duration = 3 }) print("✅ โหลดระบบฟาร์มอัตโนมัติแบบกะทัดรัดสำเร็จ!") print("🌱 ฟาร์ม: " .. MyFarm.Name) print("📍 พื้นที่: " .. X1 .. "," .. Z1 .. " ถึง " .. X2 .. "," .. Z2) return { Settings = Settings, UI = _G.UltimateGaGFarmUI, MyFarm = MyFarm }