EST Day/Night Cycle Script Issue

Hello!

So I made a real-time day/night cycle script which is supposed to match the time in the game with EST time.

However, when I join the game, the sun is set to it’s default location in the sky, even when it’s supposed to be nighttime, early morning, etc.

How do I fix this? There are no noticeable errors in the script…

while true do	
	local dateTime = DateTime.now()
	local universalTime = dateTime:ToUniversalTime()
	universalTime.Hour -= 5
	local estTime = DateTime.fromUniversalTime(universalTime.Year, universalTime.Month, universalTime.Day, universalTime.Hour, universalTime.Minute, universalTime.Second, universalTime.Millisecond)
	game.Lighting.TimeOfDay = estTime:FormatUniversalTime("hh:mm:ss", "en-us")
	wait(60)
end
1 Like

I had a similar issue but used this article to help, and it works for me.

I am unsure but you need to double check what your setting your start time too, maybe do a print call to see what time is printing and double check to make sure you have the right time.