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

How to apply math to vector3.new?

Asked by 10 years ago

Instead of having a brick move like

wait(.1)
part.Position = Vector3.new(x, x, x)
wait(.1)
part.Position = Vector3.new(x, x, x)
wait(.1)
part.Position = Vector3.new(x, x, x)
wait(.1)
part.Position = Vector3.new(x, x, x)
wait(.1)
part.Position = Vector3.new(x, x, x)
wait(.1)
part.Position = Vector3.new(x, x, x)
wait(.1)
part.Position = Vector3.new(x, x, x)
wait(.1)
part.Position = Vector3.new(x, x, x)
wait(.1)
part.Position = Vector3.new(x, x, x)
wait(.1)
part.Position = Vector3.new(x, x, x)

and so on. How would I shorten this and make it do with math. Like change the x value by .1 using math? So like "while true do wait(.01) part.Position = Vector3.new(x[+1], x, x) wait(.01) or something like that. Please help.

1 answer

Log in to vote
1
Answered by 10 years ago
while true do 
wait(0.1)
script.Parent.Position=script.Parent.Position+Vector3.new(0,0,.1)

Or if you want it to be able to move through things

while true do 
wait(0.1)
script.Parent.Position=script.Parent.Position+CFrame.new(0,0,.1)
Ad

Answer this question