Why does npc walk in a circle

For some reason, when the npc is chasing a player and when it walks on thse stairs it gets stuck by walking in a circle


but when i change the hipheight to 5 which originally is 9, it can walk normally

npc stuck.rbxl (445.2 KB)
the main script is in serverscriptservice and it uses noobpath module which is in serverstorage

2 Likes

the problem is pathfindingservice thinks that it is shorter to turn , i think your script may be creating paths over and over until it reaches the target

1 Like

is there a way to fix it please?

1 Like

your script uses oop which i am good at , just make 1 path and when the monster reaches the end of the path make another one

It is likely because you are pathfinding too frequently. I recommend reducing the number of new paths you create to see if that remedies the issue.

Roblox’s PathfindingService is good but can have its issues. Unfortunately, this is one of them—if you use “ClickToMove” you will notice similar problems.

There is no direct way to resolve this problem apart from working around it.

Your visualization of the points is helpful; it seems you are pathfinding every few seconds.
You can make it so a new path is created after no new points have been met after a duration.
This may be a better approach.

So instead of creating a new one every few seconds, you can compare the time the rig met the last point and then decide if it should be recalculated.
May also save on performance, as you would only calculate when needed.