local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local Workspace = game:GetService("Workspace") local RunService = game:GetService("RunService") local CoreGui = game:GetService("CoreGui") local LOCAL_PLAYER = Players.LocalPlayer local STAGE_COUNT = 16 local STAGE_PREFIX = "Stage" local STAGE_PAD = 2 local TARGET_SUBPATH = {"Sign", "TouchInterest"} local KEY_TOGGLE = Enum.KeyCode.F local REFRESH_INTERVAL = 5 -- seconds local ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = "AutofarmUI" ScreenGui.IgnoreGuiInset = true ScreenGui.ResetOnSpawn = false ScreenGui.Parent = CoreGui task.spawn(function() while task.wait(2) do if ScreenGui.Parent ~= CoreGui then ScreenGui.Parent = CoreGui end end end) local MainFrame = Instance.new("Frame") MainFrame.Size = UDim2.new(0, 220, 0, 85) MainFrame.Position = UDim2.new(0.5, -110, 0.2, 0) MainFrame.BackgroundColor3 = Color3.fromRGB(25, 25, 25) MainFrame.BorderSizePixel = 0 MainFrame.Active = true MainFrame.Draggable = true MainFrame.Parent = ScreenGui local UICorner = Instance.new("UICorner", MainFrame) UICorner.CornerRadius = UDim.new(0, 12) local TitleBar = Instance.new("TextLabel") TitleBar.Size = UDim2.new(1, 0, 0, 25) TitleBar.BackgroundColor3 = Color3.fromRGB(35, 35, 35) TitleBar.BorderSizePixel = 0 TitleBar.Font = Enum.Font.GothamBold TitleBar.Text = "Autofarm" TitleBar.TextSize = 14 TitleBar.TextColor3 = Color3.fromRGB(255, 255, 255) TitleBar.Parent = MainFrame Instance.new("UICorner", TitleBar).CornerRadius = UDim.new(0, 12) local StatusLabel = Instance.new("TextLabel") StatusLabel.Size = UDim2.new(1, 0, 1, -40) StatusLabel.Position = UDim2.new(0, 0, 0, 25) StatusLabel.BackgroundTransparency = 1 StatusLabel.Font = Enum.Font.GothamBold StatusLabel.Text = "Status: OFF" StatusLabel.TextSize = 20 StatusLabel.TextColor3 = Color3.fromRGB(255, 75, 75) StatusLabel.Parent = MainFrame local ToggleNote = Instance.new("TextLabel") ToggleNote.Size = UDim2.new(1, 0, 0, 15) ToggleNote.Position = UDim2.new(0, 0, 1, -15) ToggleNote.BackgroundTransparency = 1 ToggleNote.Font = Enum.Font.Gotham ToggleNote.Text = "Toggle: F" ToggleNote.TextSize = 12 ToggleNote.TextColor3 = Color3.fromRGB(200, 200, 200) ToggleNote.TextStrokeTransparency = 0.7 ToggleNote.Parent = MainFrame local function updateUI(isOn) if isOn then StatusLabel.Text = "Status: ON" StatusLabel.TextColor3 = Color3.fromRGB(75, 255, 100) else StatusLabel.Text = "Status: OFF" StatusLabel.TextColor3 = Color3.fromRGB(255, 75, 75) end end do local ok, pg = pcall(function() return LOCAL_PLAYER and LOCAL_PLAYER:WaitForChild("PlayerGui", 2) end) if ok and pg then local confetti = pg:FindFirstChild("ConfettiGui") if confetti then pcall(function() confetti:Destroy() end) end end end task.spawn(function() local pg = LOCAL_PLAYER:WaitForChild("PlayerGui", 5) if not pg then return end local mainUI = pg:WaitForChild("MainUI", 5) if not mainUI then return end mainUI.ChildAdded:Connect(function(child) if child.Name == "WinsPopup" then task.defer(function() if child.Parent then pcall(function() child:Destroy() end) end end) end end) local existing = mainUI:FindFirstChild("WinsPopup") if existing then pcall(function() existing:Destroy() end) end end) local enabled = false local lastRefresh = 0 local cachedTargets = {} local conn local function stageName(idx) return STAGE_PREFIX .. string.format("%0" .. tostring(STAGE_PAD) .. "d", idx) end local function resolvePathNonYield(base, pathArr) if not base then return nil end local cur = base for i = 1, #pathArr do cur = cur and cur:FindFirstChild(pathArr[i]) if not cur then return nil end end return cur end local function resolveToBasePart(inst) if not inst then return nil end if inst:IsA("BasePart") then return inst end if inst.Parent and inst.Parent:IsA("BasePart") then return inst.Parent end local node = inst for i = 1, 6 do node = node.Parent if not node then break end if node:IsA("BasePart") then return node end end return nil end local function refreshTargets() local track = Workspace:FindFirstChild("Track") local found = {} if not track then cachedTargets = {} lastRefresh = tick() return end for i = 1, STAGE_COUNT do local st = track:FindFirstChild(stageName(i)) if st then local resolved = resolvePathNonYield(st, TARGET_SUBPATH) local part = resolveToBasePart(resolved) found[i] = part else found[i] = nil end end cachedTargets = found lastRefresh = tick() end local function fireTouchSafe(rootPart, targetPart) if not rootPart or not targetPart then return end if type(firetouchinterest) == "function" then firetouchinterest(rootPart, targetPart, 0) firetouchinterest(rootPart, targetPart, 1) elseif type(firetouch) == "function" then firetouch(rootPart, targetPart) elseif type(__firetouchinterest) == "function" then __firetouchinterest(rootPart, targetPart, 0) __firetouchinterest(rootPart, targetPart, 1) end end local function getRootPart() local char = LOCAL_PLAYER and LOCAL_PLAYER.Character if not char then return nil end return char:FindFirstChild("HumanoidRootPart") or char:FindFirstChild("Torso") or char:FindFirstChild("UpperTorso") end local function startHeartbeatLoop() if conn then conn:Disconnect() end conn = RunService.Heartbeat:Connect(function() if not enabled then return end local root = getRootPart() if not root then return end if tick() - lastRefresh >= REFRESH_INTERVAL then refreshTargets() end for i = 1, STAGE_COUNT do local part = cachedTargets[i] if part and part.Parent then fireTouchSafe(root, part) end end end) end UserInputService.InputBegan:Connect(function(input, gp) if gp then return end if input.KeyCode == KEY_TOGGLE then enabled = not enabled updateUI(enabled) if enabled then refreshTargets() startHeartbeatLoop() else if conn then conn:Disconnect() conn = nil end end end end) refreshTargets() updateUI(false)