Need help with Pathfinding

Yeah, there are a few things you could do.

Firstly, while loops aren’t considered to be very efficient and developers tend to use RunService to handle things you could with while loops.

Secondly, I would recommend using module scripts to keep the script organised and easy to use. Using an Object-Oriented approach would be even better but its slightly more advanced.

Finally, (this is a pretty advanced subject but its very important especially when working with other developers or sharing your code) you should use custom types and type checking to make your script easier to use and understand.

If you want to learn more on these topics I suggest you read these posts:

1 Like