MoveTo
For thread safety, this property is not safe to read in an unsynchronized thread.
This function causes the Humanoid
to attempt to walk to the given location by setting the Humanoid/WalkToPoint
and Humanoid/WalkToPart
properties.
The location and part parameters correspond with what Humanoid/WalkToPoint
and Humanoid/WalkToPart
will be set to.
If the part parameter is specified, the Humanoid
will still attempt to walk to the point. However, if the part moves then the point the Humanoid
is walking to will move to be at the same position relative to the part. If the part parameter is not specified, then the position the Humanoid
is walking to will not change.
The reach goal state of a humanoid will timeout after 8 seconds if it doesn’t reach its goal. This is done so that NPCs won’t get stuck waiting for Humanoid/MoveToFinished
to fire. If you don’t want this to happen, you should repeatedly call MoveTo so that the timeout will keep resetting.
Parameters
Name | Type | Default | Description |
---|---|---|---|
|
The position to set |
||
nil
|
The |
Returns
Return Type | Summary |
---|---|
Code Samples
Humanoid MoveTo Without Time out
This code sample includes a function that avoids the 8 second timeout on Humanoid/MoveTo
by calling Humanoid/MoveTo
again before the timeout elapses. It also includes an optional andThen parameter where developers can pass a function to be called when the humanoid reaches its destination.