Need help making a day and night script that follows UTC time

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to make a day and night cycle that follows UTC. I currently have a basic day and night script that doesn’t follow UTC time.

  2. What is the issue? I can’t find a tutorial on Youtube or on the DevForum on how to make something like this.

  3. What solutions have you tried so far? I did look for solutions on the DevForum, but i couldn’t find any good ones.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

localscript

local function time()
	local t = tick()

	local hours = math.floor(t /3600) %24
	local mins = math.floor(t /60) %60
	local secs = math.floor(t) %60

	if hours <10 then
		hours = "0"..tostring(hours)
	end
	if mins <10 then
		mins = "0"..tostring(mins)
	end
	if secs <10 then
		secs = "0"..tostring(secs)
	end

	return hours..":"..mins..":"..secs
end

while wait() do
	game.Lighting.TimeOfDay = time()
end

Little proof of it working:
image
image

1 Like

Put it in ServerScriptService?

StarterPlayer ----> StarterPlayerScripts I think.

I put it in ServerScriptService as a normal script and it worked

That would be for every player instead of that one players time area.

Oh yeah I forgot to mention it’s for my train game