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

How could I do this?

Asked by 8 years ago

So recently, I got help from someone showing me how to do something like this: 0:10 0:08 0:07 and so on.

I tried to make something that goes like this for minutes: 1:02 1:01 1:00 0:59 and so on, but it's not working so I was wondering if someone could show me how to implement this. Thank you!

Countdown:

function roundCountdown()
    for countDown = 10, 0, -1 do
        playerNotification('Time left!')
    if countDown > 9 then
        playerCountdown('0:'..countDown)
    else
        playerCountdown('0:0'..countDown)
            wait(1)
        end
    end
end

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

You have the wait inside the else block, so it isn't going to wait if countDown > 9 is true.

Use two for loops to handle minutes if you don't want to use modulo. You can shorten it more by using string.format:

function roundCountdown()
    for min=2,0,-1 do
        for sec=59,0,-1 do
            playerNotification('Time left!')
            playerCountdown(string.format("%d:%.2d",min,sec))
            wait(1)
        end
    end
end
Ad

Answer this question