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

How would I use MoveTo?/Or fix this MoveTo?

I am trying to make a cart move on its own, and I know it uses MoveTo, the Wiki post explains nothing.


while true do
wait(math.random(1,4))
for i = -24.6, 29.2, 1 do
 cart = game.Workspace.Cart
   cart:MoveTo (10, 4, i)
  wait(0.001)
	end
end

Did not see any errors, I would like an explanation on how to use MoveTo, and possibly how to fix this. All help is appreciated, thanks!

1 answer

✓ Accepted answer

:MoveTo requires a Vector3 argument, you are giving three number arguments.

Example: game.Workspace.Model:MoveTo(Vector3.new(10, 4, i))

Also, if you're using a variable that you only need in one function/for do loop/etc. you can use local Name = Value

while true do
	wait(math.random(1,4))
	for i = -24.6, 29.2, 1 do
		local cart = game.Workspace.Cart
		cart:MoveTo(Vector3.new(10, 4, i))
		wait() -- default is the same.
	end
end

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