-- 1. Setup Global States getgenv().YellowOrbActive = false getgenv().GemActive = false getgenv().RedOrbActive = false -- 2. Clean up any existing instances of this GUI to prevent duplicates local oldGui = game:GetService("CoreGui"):FindFirstChild("UltimateAutofarmGUI") or game:GetService("Players").LocalPlayer:FindFirstChildOfClass("PlayerGui"):FindFirstChild("UltimateAutofarmGUI") if oldGui then oldGui:Destroy() end -- 3. Create the UI Layout local ScreenGui = Instance.new("ScreenGui") local MainFrame = Instance.new("Frame") local Title = Instance.new("TextLabel") local UIListLayout = Instance.new("UIListLayout") local UICorner_Frame = Instance.new("UICorner") ScreenGui.Name = "UltimateAutofarmGUI" ScreenGui.ResetOnSpawn = false local success, err = pcall(function() ScreenGui.Parent = game:GetService("CoreGui") end) if not success then ScreenGui.Parent = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui") end -- Design Main Window Frame (Expanded height to 310 to fit everything cleanly) MainFrame.Name = "MainFrame" MainFrame.Size = UDim2.new(0, 220, 0, 310) MainFrame.Position = UDim2.new(0.5, -110, 0.4, -155) MainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 35) MainFrame.Active = true MainFrame.Draggable = true MainFrame.Parent = ScreenGui UICorner_Frame.CornerRadius = UDim.new(0, 10) UICorner_Frame.Parent = MainFrame -- Design Title Label Title.Name = "Title" Title.Size = UDim2.new(1, 0, 0, 40) Title.BackgroundTransparency = 1 Title.Text = "Multi-Orb Farm [H]" Title.TextColor3 = Color3.fromRGB(255, 255, 255) Title.Font = Enum.Font.SourceSansBold Title.TextSize = 18 Title.Parent = MainFrame -- Automatic layout to stack buttons cleanly below the title UIListLayout.Parent = MainFrame UIListLayout.SortOrder = Enum.SortOrder.LayoutOrder UIListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center UIListLayout.Padding = UDim.new(0, 10) -- Helper function to quickly build unified style buttons local function createFarmButton(name, text, layoutOrder) local button = Instance.new("TextButton") local corner = Instance.new("UICorner") button.Name = name button.Size = UDim2.new(0, 190, 0, 40) button.BackgroundColor3 = Color3.fromRGB(200, 50, 50) -- Default Red (Off) button.Text = text .. ": OFF" button.TextColor3 = Color3.fromRGB(255, 255, 255) button.Font = Enum.Font.SourceSansBold button.TextSize = 14 button.LayoutOrder = layoutOrder button.Parent = MainFrame corner.CornerRadius = UDim.new(0, 6) corner.Parent = button return button end -- Create the 3 functional farming buttons local YellowButton = createFarmButton("YellowButton", "Yellow Orbs", 1) local GemButton = createFarmButton("GemButton", "Gems", 2) local RedButton = createFarmButton("RedButton", "Red Orbs", 3) -- Create the Master Switch Button (Uses a distinct gray/blue theme) local MasterButton = createFarmButton("MasterButton", "TOGGLE ALL", 4) MasterButton.BackgroundColor3 = Color3.fromRGB(60, 60, 70) MasterButton.Text = "ALL OFF" -- 4. Setup Remote Event Logic local replicatedStorage = game:GetService("ReplicatedStorage") local orbEvent = replicatedStorage:WaitForChild("rEvents"):WaitForChild("orbEvent") -- 5. Individual Loop Logic Functions local function startYellowLoop() task.spawn(function() local args = { "collectOrb", "Yellow Orb", "City" } while getgenv().YellowOrbActive do orbEvent:FireServer(unpack(args)) task.wait() end end) end local function startGemLoop() task.spawn(function() local args = { "collectOrb", "Gem", "City" } while getgenv().GemActive do orbEvent:FireServer(unpack(args)) task.wait() end end) end local function startRedLoop() task.spawn(function() local args = { "collectOrb", "Red Orb", "City" } while getgenv().RedOrbActive do orbEvent:FireServer(unpack(args)) task.wait() end end) end -- Helper visual state updates local function updateYellowVisual(state) getgenv().YellowOrbActive = state if state then YellowButton.BackgroundColor3 = Color3.fromRGB(50, 180, 50) YellowButton.Text = "Yellow Orbs: ACTIVE" startYellowLoop() else YellowButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50) YellowButton.Text = "Yellow Orbs: OFF" end end local function updateGemVisual(state) getgenv().GemActive = state if state then GemButton.BackgroundColor3 = Color3.fromRGB(50, 180, 50) GemButton.Text = "Gems: ACTIVE" startGemLoop() else GemButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50) GemButton.Text = "Gems: OFF" end end local function updateRedVisual(state) getgenv().RedOrbActive = state if state then RedButton.BackgroundColor3 = Color3.fromRGB(50, 180, 50) RedButton.Text = "Red Orbs: ACTIVE" startRedLoop() else RedButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50) RedButton.Text = "Red Orbs: OFF" end end -- 6. Interactive Click Listeners YellowButton.MouseButton1Click:Connect(function() updateYellowVisual(not getgenv().YellowOrbActive) end) GemButton.MouseButton1Click:Connect(function() updateGemVisual(not getgenv().GemActive) end) RedButton.MouseButton1Click:Connect(function() updateRedVisual(not getgenv().RedOrbActive) end) -- Master Toggle Button Logic local masterState = false MasterButton.MouseButton1Click:Connect(function() masterState = not masterState if masterState then MasterButton.BackgroundColor3 = Color3.fromRGB(0, 120, 255) MasterButton.Text = "ALL ACTIVE" updateYellowVisual(true) updateGemVisual(true) updateRedVisual(true) else MasterButton.BackgroundColor3 = Color3.fromRGB(60, 60, 70) MasterButton.Text = "ALL OFF" updateYellowVisual(false) updateGemVisual(false) updateRedVisual(false) end end) -- 7. Keybind Handler: Press "H" to Hide/Show Menu local userInputService = game:GetService("UserInputService") userInputService.InputBegan:Connect(function(input, gameProcessed) -- Don't trigger if the user is typing in the game chat room if gameProcessed then return end if input.KeyCode == Enum.KeyCode.H then MainFrame.Visible = not MainFrame.Visible end end)