I made a npc following part system using pathfindingService
local p2 = workspace.bitcerrr
local ai = game:GetService('PathfindingService')
while wait(0.01) do
local path = ai:FindPathAsync(workspace.RealJoyface.PrimaryPart.Position, p2.Position)
path:ComputeAsync(workspace.RealJoyface.PrimaryPart.Position, p2.Position)
local ways = path:GetWaypoints()
if path.Status == Enum.PathStatus.Success then
for _, v in ipairs(ways) do
workspace.RealJoyface.Humanoid:MoveTo(v.Position)
workspace.RealJoyface.Humanoid.MoveToFinished:Wait()
end
end
end
But I don’t like how the NPC walks in a straight path
I try to remove workspace.RealJoyface.Humanoid.MoveToFinished:Wait()
But this makes him ignore the path completely.
It’s because you’re calculating new path every 0.01 second. The delay is so fast, that it looks like NPC is standing still. Try waiting for the NPC to reach the next waypoint, after what calculating a new path.