How to prevent pathfinding from going all the way to destination

local function pathfindToDestenation(rigToMove, finishPos)
	local humanoid = rigToMove:WaitForChild("Humanoid")
	local humanoidRootPart = rigToMove:WaitForChild("HumanoidRootPart")

	local path = PathfindingService:CreatePath()
	path:ComputeAsync(humanoidRootPart.Position, finishPos)
	local waypoints = path:GetWaypoints()

	for _, waypoint in waypoints do
		humanoid:MoveTo(waypoint.Position)
		humanoid.MoveToFinished:Wait()
	end
	print("Finished")
end

the problem is that the humanoids go to the table at and then they get stuck because they are not fully at their destination. how do i fix this? (its not printing “Finished”)

Keep looping the path until it’s a certain distance from your destination. Path finding has a timeout time which is very annoying.

1 Like
	for i, waypoint in waypoints do
		humanoid:MoveTo(waypoint.Position)
		if i >= #waypoints - 2 then
			break
		end
		humanoid.MoveToFinished:Wait()
	end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.