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

How to loop a for loop?

Asked by 9 years ago
for i = 1, 360, 1 do
    wait()
    print(i)
    script.Parent.Rotation = i
end

This simple for loop makes an image rotate around, but once i = 360 it stops. How can I get this so the image constantly spins around, instead of spinning once and then stopping?

0
Wrap your for loop in a while loop, it will make it run forever that way. Spongocardo 1991 — 9y

1 answer

Log in to vote
2
Answered by
Redbullusa 1580 Moderation Voter
9 years ago

You can nest this "for" loop in a "while" loop.

while true do
    for i = 1, 360 do
        wait()
        print(i)
        script.Parent.Rotation = i
    end
end
1
Are you serious lol. I hate when people ninja me. I'll delete my answer. Shawnyg 4330 — 9y
Ad

Answer this question