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

local GameLength = 300

while true do

for i = GameLength, 0, -1 do 
Status.Value = "There are "..i.." seconds remaining"
wait(1)
end

end

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

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

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

Revised Server Script

local GameLength = 300

while true do
    for i = GameLength, 0, -1 do
        local minutes = math.floor(i / 60)
        local seconds = i - (minutes * 60)
        Status.Value = (minutes..":"..seconds)
        wait(1)
    end
end
0
it works. thanks then jacobian65 19 — 5y
Ad

Answer this question