So basically I’m trying to understand Pathfinding, and I understand most of it quite well but after two tutorials and reading the Wiki page I cannot figure out what Humanoid.MoveToFinished:Wait() does in the following script. I understand what the function itself does but not what it does in this script:
When your pathfinder is moving to the point you set it to, MoveToFinished:Wait()
waits until it’s done moving.
Imagine if the wait were not there: What would happen?
The loop would run to completion immediately, and all off the MoveTo’s would just override one and other, ending up with the Humanoid moving directly to the very last waypoint, ignoring the others.
Sourced from Handling Events
Basically, the script will be paused until the event fires / occurs, so that the script will have to wait until the humanoid has reached a waypoint (or if 8 seconds has passed) before proceeding to walk to the next waypoint. If the :Wait()
wasn’t there, the script will iterate over the table almost instantaneously, resulting in all of the MoveTo
functions to be invoked almost simultaneously, making all of them be overridden by another