Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

can anyone give me an example on how to use API:model/moveto ? [closed]

Asked by 9 years ago

This question already has an answer here:

is it possible to re-position a model ?

i dont understand how to use it http://wiki.roblox.com/index.php?title=API:Class/Model/MoveTo

Marked as Duplicate by Goulstem and M39a9am3R

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 9 years ago

Hello,

With MoveTo, you have to define the models PrimaryPart, which is basically the models main part! Then you can use MoveTo to move the model according the PrimaryPart.

Example:

--This script would move the model in workspace called tree, according to its PrimaryPart called 'Trunk' to a random position every 5 seconds.
local tree = game.Workspace.Tree
tree.PrimaryPart = tree.Trunk

while wait(5) do
    tree:MoveTo(Vector3.new(tree.PrimaryPart.Position + Vector3.new(math.random(-10,10), 0, math.random(-10,10))))
end

Hope this helps, Brandon. <3

1
You don't have to set the PrimaryPaty prior to using the MoveTo method, although it is reccomended. If it's not set then the root of the model will be used for the relative Position. Goulstem 8144 — 9y
Ad