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

How do I make a clock GUI with a day/night cycle?

I need to make a day/night cycle with a working digital clock displayed at the bottom of a player’s screen. 8 minute day, 2 minute night. Also with days of the week. Please reply if you know how to script this!

1 comment

0

Well I’m not sure if that’s possible maybe you can just do a script that goes to a certain time

1 answer

It's more difficult if you want the digital clock's numbers to be images, but if you can find a font you like, it's easier. What you'll need to do:

  • Have a server script that manages what the current time is, or you could just use workspace.DistributedGameTime and perform % (secondsInDay) to get the current time-of-day in seconds -- secondsInDay = (8 + 2) * 60 -- or 600.
  • You need to periodically update the clock (either after every wait() or faster if you want to use the RunService).
  • Set up the gui (ex in StarterGui)
  • Get a LocalScript that updates the numbers in the gui
  • A mix of modulus and division is useful when doing time management -- ex, say you wanted to convert 153 seconds into seconds and minutes? math.floor(153/60) == 2 and 153 % 60 == 33. You can then combine the two numbers, ex using string.format("%s:%s", minutes, seconds) to get 2:33.
  • If you have FilteringEnabled on and aren't just using workspace.DistributedGameTime, you'll need to use a RemoteFunction to ask for the time (possibly only once, depending on how you advance the time on the server). You will need to keep the value up-to-date on the local script (which is easy if it's progressing in real time as you can just base it off of tick().)

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