I’ve recently been playing around with pathfinding for NPC’s, and everything works perfectly fine besides for one issue. The NPC won’t start moving until I get close to it.
Here’s a video of what I mean:
And here’s the script behind it: (Note this is in a local script in starter player)
local PFS = game:GetService("PathfindingService")
local Bob = workspace.Bob
while true do
local TargetRoom = workspace.Map.Rooms["Room" .. math.random(1,9)]
local Path = PFS:CreatePath({
AgentRadius = 3
})
local S, E = pcall(function()
Path:ComputeAsync(Bob.PrimaryPart.Position, TargetRoom.Boundries.Area.Position)
end)
for i, v in pairs(Path:GetWaypoints()) do
Bob.Humanoid:MoveTo(v.Position)
Bob.Humanoid.MoveToFinished:Wait()
end
end
Oddly enough it seems that the distance that triggers the NPC’s movement increases over time. Also, if you chase Bob around the map enough, it’ll eventually start working as intended.
I’m pretty new to pathfinding service so I could very well be doing something wrong, I just don’t no what that is. Any help is appreciated.