PathFinding for loop stop

Hello I’m trying to move alot of npc at once and be able to change the direction whend a input comes i dont know how to stop the first command to move to a point the script that i have is these