PathfindingService Help

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.

Can someone help me?

I guess theres no solution for this

Still waiting for someone to reply :confused:

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.

not what i really was expecting

Again, you’re waiting for the NPC to finish the whole path. Wait NPC to walk to the first waypoing, not the end of the path.

putting a wait() in the ipairs thing still doesnt help, he still reaches the end
image

yeah im going to give up on this