Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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!

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

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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().)
Ad

Answer this question