Help with a TimeOfDay Changer please?


I am creating a local TimeOfDay Editor, for a Theme Change Option in my Game.

For some reason, although the Time of Day Changes, the Time is not what I want it to be.

As follows is my Code for changing the Time of Day to 04:00:00

local lighting = game.Lighting
	lighting.TimeOfDay = 040000
	print("time set to".. game.Lighting.TimeOfDay)

The end print says…
time set to 16:00:00

This is not what I want, as that’s not 04:00:00! The Sky is also a strong blue, showing that it is Day Time, or the time which 16:00:00 is.

I feel it might be me putting numbers wrong, and there is nothing bad in the Output.

Regards, AridOats.

1 Like

You cant directly change the day time. You need to use Lighting:SetMinutesAfterMidnight(). In your case use this


You aren’t setting the property right. The TimeOfDay property is a string, not a number. Your code should be:

lighting.TimeOfDay = "04:00:00"

Oh right! Thanks! It works perfectly!
Guess I’ll have to settle down to some Math then…!

Thanks Again. :smile:

That works just as well too. Thank you.
Shame I can only give one Solution! :sweat_smile: