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

My rocket moves to the desired increment, but the rest become 1 stud increments?

Asked by 4 years ago

Code I have so far:

for b = 10,100 do 
            game.Workspace.Rocket:MoveTo(Vector3.new(38, 67.171+b, -168.25))
            wait(0.5)
        end

So when my rocket is launched, the very first increment is 10. After that increment of movement is done, it goes on to be 1 increment movements! This is my first time using for loops, could someone help me with the problem?

1 answer

Log in to vote
1
Answered by 4 years ago

For loops work like this:

for [Starting Value], [Last Value], [Optional: Number of increment, if not defined, it will be 1 by default]

The loop will go until the Starting Value will reach the Last Value and the Starting Value will be increased by the Optional Value or 1 if not defined.

So by saying: for b = 10,100 do the B value will start at 10 and will increase by 1 (as you didn't define optional value) which means when you add B for the first time to 67 it will be 77 and the next time it will be 78 as B was increased by 1 which means it changed from 10 to 11. For example: If you want to be increased by 10 each time you need to for b = 10,100, 10 do

Ad

Answer this question