The problem I'm having with my script is that on the second cycle of the moon, it permanently sets the outdoor ambience and ambience to the dark version and does not fix itself. As well as that I would appreciate tips on how to make it a smoother transition. Here is the code I'm having trouble with.
local MinutesAfterMidnight = 0 while true do game.Lighting:SetMinutesAfterMidnight(MinutesAfterMidnight) MinutesAfterMidnight = MinutesAfterMidnight + 10.5 wait(0.1) if MinutesAfterMidnight >= 6 * 60 and MinutesAfterMidnight <= 18 * 60 then game.Lighting.Brightness = 1 game.Lighting.OutdoorAmbient = Color3.new(97/255, 97/255, 97/255) game.Lighting.Ambient = Color3.new(5/255, 5/255, 5/255) end if MinutesAfterMidnight >= 18 * 60 or MinutesAfterMidnight <= 6 * 60 then game.Lighting.Brightness = 0 game.Lighting.OutdoorAmbient = Color3.new(5/255, 5/255, 5/255) game.Lighting.Ambient = Color3.new(2/255, 2/255, 2/255) end end
As a side note after looking at the world lighting while running it, on the second moon cycle the OutdoorAmbient and Ambient did not change when the sun came up. Also the sky itself seemed to have darkened halfway through the night.
Try this:
l = game:service("Lighting") r = game:service("RunService") while true do l:SetMinutesAfterMidnight(l:GetMinutesAfterMidnight()+1) wait(.2) end