hi there, I had a timer script that will output a timer like this screenshot.
here is the code.
for i = GameLength, 0, -1 do local minutes = math.floor(i / 60) local seconds = i - (minutes * 60) Status.Value = (minutes..":"..seconds) wait(1) end
so my question is how to make the timer more intuitive by adding a 0 after counting down from 10. like this screenshot.
thanks
This has been covered many times, e.g. in this thread on the devforums.
Essentially, you can use the string.format function to format the seconds string padded with 0s to a specific width, e.g.
for i = 101, 1, -1 do print(string.format( "%.3i", i )) end
prints the numbers from 101 to 1 padded with 0s to a width of 3 (indicated by the number between '.' and 'i', so e.g. 54 becomes 054 and 3 becomes 003.