hi there, I am trying to change the seconds of timing in my game to turn it to use minute instead. currently it look like this.
here is the code
01 | local GameLength = 300 |
02 |
03 | while true do |
04 |
05 | for i = GameLength, 0 , - 1 do |
06 | Status.Value = "There are " ..i.. " seconds remaining" |
07 | wait( 1 ) |
08 | end |
09 |
10 | end |
now my question is how to turn it to use minutes instead of second. like this screenshot.
any help would be appreciated. thanks
Simply calculate the minutes and seconds using the current time (i) with
1 | local minutes = math.floor(i / 60 ) |
2 | local seconds = i - (minutes * 60 ) |
math.floor returns the number rounded down to the nearest integer
Revised Server Script
01 | local GameLength = 300 |
02 |
03 | while true do |
04 | for i = GameLength, 0 , - 1 do |
05 | local minutes = math.floor(i / 60 ) |
06 | local seconds = i - (minutes * 60 ) |
07 | Status.Value = (minutes.. ":" ..seconds) |
08 | wait( 1 ) |
09 | end |
10 | end |