The pathfinding service is good for moving to a stationary target, however I have struggled to use it to make an AI mob which moves to a moving target (the player). I did try using a mixture of raycasting and pathfinding, but trying to constantly update the pathfinding always creates a really buggy output. Could anyone help?
COMMUNITY QUESTION
How do I make an AI which moves to the player?
1 answer
If the AI is made with a humanoid object, you can use humanoid:MoveTo(position, target). It takes in the target's position and the target in order to change direction if the target moves. I'm pretty sure that the function doesn't stop until it reaches the target location. You can read more about it here - https://developer.roblox.com/en-us/api-reference/function/Humanoid/MoveTo.
1 comment
0
Yeah I already about that, thats what I use to move to the node positions on the GetWaypoint function of pathfinding. If I simply do a loop of moving to the players position the Ai will simply walk in a straight line and not avoid any terrain in the way
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Have you tried using Humanoid:MoveTo to move the NPCs to the player's position? https://developer.roblox.com/en-us/api-reference/function/Humanoid/MoveTo
Yeah I already about that, thats what I use to move to the node positions on the GetWaypoint function of pathfinding. If I simply do a loop of moving to the players position the Ai will simply walk in a straight line and not avoid any terrain in the way