0

I'm trying to make a timer that goes on repeat a certain number of times, but it just comes out as an infinite loop. In the following code, only s is ever printed never a, so the program isn't even entering the timer. Any help would be really appreciated

k = 10
sec = 10
i = 0
it = 3
while (i < it) do
    text.text = sec
    print("s")
    timer.performWithDelay( 1000, function () 
        print("a")
        sec = sec - 1
        text.text = sec
        if (sec == 0) then
            i = i + 1
            sec = k
        end
    end, k)
end

0 Answers0