AI Pathfinding (Help)

I wrote a script which will guide an NPC to a position. The script worked for the most part and the NPC got there successfully, however the part where it should have instanced parts which would represent waypoints didn’t work (I have highlighted that part of the script). Please help me out.

3fa9e70ea82708e0b293ff68610d2080

Hey there!
Before we jump into this, Could you please provide us with errors if you have any?
From my point, it looks like your script should work as intended.

As a side note, :Wait() does not take a parameter, so that 2 in there is redundant.
One more thing, from the loop, it looks like you want to move your humanoid from one point to the other until it reaches the end. I am unsure of why you repeat :MoveTo after the loop. I dont thing you need it there. (If I’m misunderstanding anything, feel free to let me know)

Edit:
Oh and as a heads up, instead of using

part.Shape = "Ball"
part.Material = "Neon"

I would recommend using enums:

part.Shape = Enum.PartType.Ball
part.Material = Enum.Material.Neon

It’s generally better practice

1 Like

Hello, thank you for your response! No there were no errors in the script.

Hey! I figured out the problem! Thanks alot for your help though. Much appreciated!

1 Like