Help | change seconds to minutes and hours [still no reply please help]

hi,
i made chest system with countdown and everything almost but i still need help with the countdown of the chest, i don’t know how to change that from countdown of seconds to countdown of minutes and hours.
can anyone help me with that please?
here is the system: Chest System - Roblox
note: the system is open source so you can check the scripts.
thanks for all the help.

Hmmm it seems complicated but I think it has something to do with putting a while loop which goes off every second.
Let me see so there are 3600 seconds in an hour and 60 seconds in a minute.

thanks but will is work with os.time()?

I think you would use it to save the time people opened up the chest between sessions, right?

So maybe my thought was dividing the time in seconds of the amount of seconds in an hour, getting the remainder, then dividing it by the amount of seconds in a minute then getitng the remainder and putting it in as seconds.

Here it is, it involved some math, but heres a function you can run and maybe put into a module to run it in any script to update seconds to a format of hours:minutes:seconds, run this function every second so it counts down.

function UpdateTimer(timeLeft)
local hoursUn=(timeLeft/3600)
local Hours=math.floor(hoursUn)
local minUn=timeLeft/60
local minu= (math.floor(minUn)-(Hours*60))
local sec=(timeLeft-(math.floor(minUn)*60))
print(Hours .. “:” .. minu .. “:” .. sec)
end

As you can see it takes some math and it took me some time cause I never wrote one of these scripts before, send me feedback if anything goes wrong, I hope it works fine.
Edit:
Sorry, made a mistake on coding the seconds part it should be fixed now. Never hurts to correct

1 Like

but the thing that i want to do is just replace the text to like: 00:00:00 h/m/s

You will find the answer to your problem here:

1 Like

alright, thank you @RoundfIy333