Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is it possible to use TimeOfDay as a digital clock?

So I was experimenting with Roblox scripting and I wanted make a little clock at the top of the screen for my Roblox game, I currently have a working day/night cycle. So my entire goal is to use the TimeOfDay property off lighting as a digital clock like in this format

12:00

If this is impossible I truly understand. Thank you in advance

1 answer

✓ Accepted answer

Hey there, totally possible! You just have to learn how to use the Lua string library.

I searched up the TimeOfDay property of Lighting and found this on the wiki:

game.Lighting.TimeOfDay = "00:00:00"

This format is HH:MM:SS, so to get it into HH:MM, simply remove the :SS

local Lighting = game.Lighting
print(Lighting.TimeOfDay:sub(1, 5))

Hope that helps!

3 comments

0

Thank you so much

0

or go overkill and use the % opperator on GetMinutesAfterMidnight :>

0

Yeah, you could use gsub or match, but given that the format is always the same, it makes the most sense to use the simple substring function.

This discussion is preserved as it was. New answers, comments, and votes are closed.