Make NPC walk through waypoints that changes every time when the nearest player changed

I am making a horror game where the location is a maze, theres 1 monster that will always chase the
nearest player. The way how it checks the nearest player is by looping every frames and overriding the nearest player variable.

The problem with Pathfinding Service is that the nearest player can be anyone and changes every time, therefore the waypoints also gets changed. Looping through all waypoints with yield the code and it will not go to the next nearest player until its over.

How would I chase a dynamic player through a maze?

1 Like

Why not just stop the current path when the closest player changes, it will solve the problem easily

that actually a really good idea
cant believe didn’t think of that

thank u so much