while true do for i = 120, 0, -1 do status.Value = "Time left: " ..i wait(1) end end
This script counts down from 120 seconds to zero. How would I make the 120 look like 2:00 minutes?
You can use division to see how many minutes are left and then modulo
or %
to find out the seconds left.
Remove The space between % 02d
. The site will not show them if they are together.
while true do for i = 120, 0, -1 do status.Value = ("Time Left: %d:% 02d"):format(math.floor(i/60),i%60) wait(1) end end
Edit: Updated script....Thanks DataStore
not sure if this would work because it just popped up, but im pretty sure it should work, we will need the integer division to find how many 60 seconds are within 120 seconds or any time length that is in seconds
local TimeLength = script.Parent.TimeLength --[[ just to get the time length (in seconds) of the parenting sound--]] local seconds = 0 local minute = 0 -- variables that will get the result minute = TimeLength // 60 -- how many 60s are there in timelength without floating point? integer division (//) does the trick seconds = TimeLength - minute --get the remaining seconds left before the next minute --FINALLY print the results (the .. part joins strings together in case you dont know what it does) print("the sound is ".. minute .. " minutes and " .. seconds .. "seconds long")
the output: "the sound is 2 minutes and 0 seconds long"