Help with a TimeOfDay Changer please?

Hello!

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
script.Parent.MouseButton1Click:Connect(function()
	lighting.TimeOfDay = 040000
	print("time set to".. game.Lighting.TimeOfDay)
end)

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.

3 Likes

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

	lighting:SetMinutesAfterMidnight(240)
4 Likes

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"
4 Likes

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: