Day/Night cycle working in studio but not in game

You can write your topic however you want, but you need to answer these questions:
I have a day/night cycle which works with os.date to get the current local time for the player (one player servers). This works in studio but not in game.

local function localTime()
    local date = os.date("*t")
    return ("%02d:%02d:%02d"):format(((date.hour)), date.min,date.sec)
end

while wait(1) do 
	game:GetService("Lighting").TimeOfDay = localTime()
end

the time of day starts at
04:45:48
image

Are you running this on the client or server? It should be ran on the client in a LocalScript.

Could you also explain further what exactly is “not working” about it.

1 Like

I should’ve mentioned this in the main post. Yes, I have it changed nothing.

Where specifically is this script located?

1 Like

For the server script the ServerScriptService, for the local script, the startergui.

Fixed my issue