MoveTo (Method): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>PurpleKiwi
Added examples
m Text replacement - "<SyntaxHighlight code="lua">" to "<syntaxhighlight lang="lua">"
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{|
{{:MoveTo (Method)/model}}
|{{:MoveTo (Method)/model}}
 
|{{Example|<pre>Workspace.Player:MoveTo(Vector3.new(0,100,0))</pre>}}
 
|-
{{Clear floats}}
|There is also a separate ''MoveTo'' method exclusively for the [[Humanoid]] object.
 
|-
 
|{{:MoveTo (Method)/humanoid}}
{{Example|
|{{Example|<pre>Workspace.Player.Humanoid:MoveTo(Workspace.Part.Position,Workspace.Part)</pre>}}
This will move the player named 'Player' to 100 studs above the center of the map (assuming the map is centered around 0, 0, 0):
|}
 
<syntaxhighlight lang="lua">Workspace.Player:MoveTo(Vector3.new(0, 100, 0))</syntaxhighlight>}}
 
There is also a separate ''MoveTo'' method exclusively for the [[Humanoid]] object.
 
 
{{Clear floats}}
 
 
{{:MoveTo (Method)/humanoid}}
 
 
{{Clear floats}}
 
 
{{Example|
This will make the player named 'Player' move to the part named 'Part', located in the Workspace:
 
<syntaxhighlight lang="lua">Workspace.Player.Humanoid:MoveTo(Workspace.Part.Position, Workspace.Part)</syntaxhighlight>}}
 


[[Category:Methods]]
[[Category:Methods]]

Latest revision as of 06:19, 27 April 2023

MoveTo( Vector3 destination )
Returns nil
Description: Moves the object and all children instantly to the destination.
Member of: Model



Example

This will move the player named 'Player' to 100 studs above the center of the map (assuming the map is centered around 0, 0, 0):

Workspace.Player:MoveTo(Vector3.new(0, 100, 0))


There is also a separate MoveTo method exclusively for the Humanoid object.



MoveTo( Vector3 location, Part part )
Returns nil
Description: Causes the character of the humanoid to walk to the location.
Member of: Humanoid



Example

This will make the player named 'Player' move to the part named 'Part', located in the Workspace:

Workspace.Player.Humanoid:MoveTo(Workspace.Part.Position, Workspace.Part)