RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"create an NPC that follows the player infinitely"
-- server script local pfs = game:GetService("PathfindingService") local npc = game.Workspace.NPC local followSpeed = 16 while true do local players = game:GetService("Players"):GetPlayers() for _, player in ipairs(players) do local character = player.Character if character then local path = pfs:CreatePath() path:ComputeAsync(npc.HumanoidRootPart.Position, character.HumanoidRootPart.Position) local waypoints = path:GetWaypoints() for _, waypoint in pairs(waypoints) do npc.Humanoid:MoveTo(waypoint.Position) npc.Humanoid.MoveToFinished:Wait() end end end wait() end