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

how to change time countdown in seconds to use minute countdown instead?

Asked by 5 years ago

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

01local GameLength = 300
02 
03while true do
04 
05for i = GameLength, 0, -1 do
06Status.Value = "There are "..i.." seconds remaining"
07wait(1)
08end
09 
10end

now my question is how to turn it to use minutes instead of second. like this screenshot.

any help would be appreciated. thanks

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Simply calculate the minutes and seconds using the current time (i) with

1local minutes = math.floor(i / 60)
2local seconds = i - (minutes * 60)

math.floor returns the number rounded down to the nearest integer

Revised Server Script

01local GameLength = 300
02 
03while 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
10end
0
it works. thanks then jacobian65 19 — 5y
Ad

Answer this question