This script is relatively simple-- the script gets the clocktime, multiplies it by 10, and sets that as the ambient in the game. It does essentially the same thing with the outdoor ambient, except it subtracts clocktime * 10
by 10.
clockTime = game.Lighting.ClockTime while true do game.Lighting.Ambient = Color3.new((clockTime * 10)/255,(clockTime * 10)/255,(clockTime * 10)/255) game.Lighting.OutdoorAmbient = Color3.new(((clockTime * 10) - 10)/255,((clockTime * 10) - 10)/255,((clockTime * 10) - 10)/255) wait(1) end
It works upon running the game- set it to any time, run the script and it works. However, I also have a simple copy/paste day-to-night cycle script running as well:
minutesAfterMidnight = 0 while true do minutesAfterMidnight = minutesAfterMidnight + 60 game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight) wait(60) end
and the ambient doesn't update with the time as it changes. Any suggestions on how to make this work? Thanks.
This is because it is only defined once. For example, if you did
local name = game.Workspace.Part.Name workspace.Part.Name = 'something' print(name)
it would not print "something". To fix this, just define it in the while loop. Also, try merging these two scripts together, as they do small tasks to get similar things done.
local minutesAfterMidnight = 0 while true do minutesAfterMidnight = minutesAfterMidnight + 60 game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight) local clockTime = game.Lighting.ClockTime game.Lighting.Ambient = Color3.fromRGB((clockTime * 10)/255,(clockTime * 10),(clockTime * 10)) game.Lighting.OutdoorAmbient = Color3.new(((clockTime * 10) - 10),((clockTime * 10) - 10)/255,((clockTime * 10) - 10)) wait(60) end
Also, you should go see this. I combined the two while loops so the ambient changing changes almost instantly from the lighting changing, instead if one script needed to load significantly longer than the other script.
Hope this helps!