I don't want to type this 1000 times because what im trying to do is change 500 and make it one less each time, 500, 499, 498,... and so on all the way to - 500. Is there a much easier way to do this than type workspace.fly.meow.positon.......1000 times?
while true do workspace.fly1.MEOW.Position = Vector3.new (500, 20, 40) wait(1) -- The bottom part is what i want it to end with ---------------------------------------------------------------------------------- workspace.fly1.MEOW.Position=Vector3.new(-500, 20, 40) wait(1) end
What you're looking for is a for
loop. The correct format of for loops looks like this:
for variable = startNumber, endNumber, increment do end
What this does is variable
will start at startNumber
, end at endNumber
, with increment
being added to variable
each time the loop iterates.
The default value of increment
is 1, so if you're just adding 1 each time you can leave it out.
for index = 1, 10, 0.5 do print(index) end
Play around with these numbers and check your output.
To change the position we just need to make startNumber
500, endNumber
-500, and increment
-1 so that one is subtracted each time.
for i = 500, -500, -1 do workspace.fly1.MEOW.Position = Vector3.new(i, 20, 40) wait(1) end