Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

1 answer

✓ Accepted answer

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 comment

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.