How do I reset "i =" loops?

So I made a loop, and I wanted to know how I would reset it back to the number 15.

for i = 15, 0, -1 do
	script.Parent.towel.Text = "Intermission: "..i..""
end
1 Like

you would have to break the loop, and restart from there.

break is a constructor that will have the code exit the loop, as in it will stop it entirely, you can then tell the code to create the same loop. break can only be used under scopes that are loops which are the following:

while
repeat
for

The last concatenation is unnessacary, it does not do anything, so you can remove that.

how would I do that when it reaches 0, would I just use a wait() or is there a specific thing?

you can have a loop outside the loop, and have it repeat, like so:

while true do -- a never ending loop
    for i = 15, 0, -1 do -- loop inside
	    script.Parent.towel.Text = `Intermission: {i}` -- This is just another way of concatenating
        task.wait(1)
    end
    -- once this loop is finished, it will repeat
end

Also, do not use wait() as that is essentially deprecated (Discontinued), you should use the newer variant: task.wait()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.