RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"npc that follows you"
-- server script local PathfindingService = game:GetService("PathfindingService") local npc = game.Workspace.NPC local followDistance = 5 while true do local players = game:GetService("Players"):GetPlayers() for _, player in ipairs(players) do local character = player.Character if character and character:FindFirstChild("HumanoidRootPart") then local distance = (npc.HumanoidRootPart.Position - character.HumanoidRootPart.Position).Magnitude if distance <= followDistance then local path = PathfindingService:CreatePath() path:ComputeAsync(npc.HumanoidRootPart.Position, character.HumanoidRootPart.Position) for _, waypoint in ipairs(path:GetWaypoints()) do npc.Humanoid:MoveTo(waypoint.Position) npc.Humanoid.MoveToFinished:Wait() end end end end wait(1) end