-- CONFIG local goldFolder = workspace:WaitForChild("Gold") local teleportDelay = 7 -- seconds local teleportHeight = 0 -- above the part local maxRange = 200 -- max distance in studs local players = game:GetService("Players") local lp = players.LocalPlayer local uis = game:GetService("UserInputService") -- STATE local enabled = false -- Function to simulate E key press local function pressE() keypress(0x45) wait(0.1) keyrelease(0x45) end -- TP to gold part local function teleportTo(part) if lp.Character and lp.Character:FindFirstChild("HumanoidRootPart") then lp.Character:MoveTo(part.Position + Vector3.new(0, teleportHeight, 0)) end end -- Loop for farming gold with range check task.spawn(function() while true do if enabled then if lp.Character and lp.Character:FindFirstChild("HumanoidRootPart") then local hrpPos = lp.Character.HumanoidRootPart.Position for _, gold in ipairs(goldFolder:GetChildren()) do if enabled and gold:IsA("BasePart") then local distance = (gold.Position - hrpPos).Magnitude if distance <= maxRange then teleportTo(gold) wait(1) pressE() wait(teleportDelay) end end end end end task.wait(0.5) end end) local ScreenGui = Instance.new("ScreenGui", game.CoreGui) ScreenGui.Name = "GoldFarmUI" local Frame = Instance.new("Frame", ScreenGui) Frame.Size = UDim2.new(0, 150, 0, 50) Frame.Position = UDim2.new(0, 200, 0, 200) Frame.BackgroundColor3 = Color3.fromRGB(255, 0, 0) Frame.BorderSizePixel = 0 Frame.Active = true Frame.Draggable = true local ToggleButton = Instance.new("TextButton", Frame) ToggleButton.Size = UDim2.new(1, 0, 1, 0) ToggleButton.BackgroundTransparency = 1 ToggleButton.Font = Enum.Font.GothamBold ToggleButton.TextSize = 16 ToggleButton.TextColor3 = Color3.fromRGB(255, 255, 255) ToggleButton.Text = "AutoFarm: OFF" local function updateUI() if enabled then Frame.BackgroundColor3 = Color3.fromRGB(0, 200, 0) ToggleButton.Text = "AutoFarm: ON" else Frame.BackgroundColor3 = Color3.fromRGB(200, 0, 0) ToggleButton.Text = "AutoFarm: OFF" end end ToggleButton.MouseButton1Click:Connect(function() enabled = not enabled updateUI() end) updateUI()