Day/Night Cycle sunrise not working right

Greetings,

I am making a day/night cycle for a new game and when it sets back to daytime, it keeps going to 0.

local lighting = game.Lighting
local timer = 300
local daytime = 14
local nighttime = 21

local daysound = game.SoundService.Day
local nightsound = game.SoundService.Night

while true do
	wait(timer)
	daysound:Stop()
	nightsound:Play()
	repeat
		wait(.1)
		lighting.ClockTime = lighting.ClockTime + .1
	until lighting.ClockTime == nighttime --sets the time to night
	wait(timer)
	nightsound:Stop()
	daysound:Play()
	repeat
		wait(.1)
		lighting.ClockTime = lighting.ClockTime - .1
	until lighting.ClockTime == daytime --sets the time to day
end

If you search day/night cycle on the forums you’ll see a whole bunch of answered posts about scripting them, along with YouTube links for tutorials. Help with Day/Night cycle

Alright, I will try that and see if it works.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.