local u=dayEnd-dayStart local W=24-u local O=true local Q=game.Lighting.FogColor while true do local v=wait(updateTick)local Z=0 if game.Lighting.ClockTime>=dayStart and game.Lighting.ClockTime<=dayEnd then Z=u/daytimeInSeconds if not O then O=true local u=TweenService:Create(game.Lighting,FogTweenInfo,{FogColor=Q})u:Play()end else Z=W/nightInSeconds if O then O=false local u=TweenService:Create(game.Lighting,FogTweenInfo,{FogColor=Color3.fromRGB(50,56,66)})u:Play()end end game.Lighting.ClockTime+=Z*v end


local hoursInDay = dayEnd-dayStart
local hoursInNight = 24-hoursInDay
local day = true

local originalFog = game.Lighting.FogColor

while true do
	local updateDelta = wait(updateTick)
	local step = 0
	if game.Lighting.ClockTime >=dayStart and game.Lighting.ClockTime <=dayEnd then
		step = hoursInDay/daytimeInSeconds
		if not day then
			day = true
			local tween = TweenService:Create(game.Lighting,FogTweenInfo,{FogColor = originalFog})
			tween:Play()
		end
	else
		step = hoursInNight/nightInSeconds
		if day then
			day = false
			local tween = TweenService:Create(game.Lighting,FogTweenInfo,{FogColor = Color3.fromRGB(50, 56, 66)})
			tween:Play()
		end
	end
	game.Lighting.ClockTime += step*updateDelta
end
