I found a lighting color change system on the devforum, and I altered it a bit. My code:
local Lighting = game:GetService("Lighting")
local increment = 0.1
local Ambients = {
["black"] = Color3.fromRGB( 0, 0, 0 ),
["dark_blue"] = Color3.fromRGB( 34, 40, 58 ),
["early_orange"] = Color3.fromRGB( 69, 60, 62 ),
["early_purple"] = Color3.fromRGB( 52, 41, 63 ),
["light_blue"] = Color3.fromRGB( 180, 210, 228 ),
["late_orange"] = Color3.fromRGB( 72, 61, 42 ),
["late_purple"] = Color3.fromRGB( 50, 38, 63 ),
}
function GetAmbient()
local ClockTime = Lighting.ClockTime
if type(ClockTime) ~= "number" then
return Ambients.light_blue
end
if ClockTime <= 3 or ClockTime >= 9 then
return Ambients.black
elseif ClockTime > 3 and ClockTime <= 4 then
return Ambients.black:lerp( Ambients.dark_blue, ClockTime - 3 )
elseif ClockTime > 4 and ClockTime <= 5.5 then
return Ambients.dark_blue:lerp( Ambients.early_orange, ( ClockTime - 4 ) / 1.5 )
elseif ClockTime > 5.5 and ClockTime <= 6 then
return Ambients.early_orange:lerp( Ambients.early_purple, ( ClockTime - 5.5 ) / 0.5 )
elseif ClockTime > 6 and ClockTime <= 6.5 then
return Ambients.early_purple:lerp( Ambients.light_blue, ( ClockTime - 6 ) / 0.5 )
elseif ClockTime > 6.5 and ClockTime <= 17.5 then
return Ambients.light_blue
elseif ClockTime > 17.5 and ClockTime <= 18 then
return Ambients.light_blue:lerp( Ambients.late_orange, ( ClockTime - 17.5 ) / 0.5 )
elseif ClockTime > 18 and ClockTime <= 18.4 then
return Ambients.late_orange:lerp( Ambients.late_purple, ( ClockTime - 18 ) / 0.4 )
elseif ClockTime > 18.4 and ClockTime <= 20 then
return Ambients.late_purple
elseif ClockTime > 20 and ClockTime <= 21 then
return Ambients.late_purple:lerp( Ambients.black, ClockTime - 20 )
end
end
while true do
Lighting.ClockTime = Lighting.ClockTime + increment
local Ambient = GetAmbient()
print(Ambient)
Lighting.ColorShift_Top = Ambient
wait()
end
I was wondering a few things:
- How could I improve this for more realism / efficiency?
- Why does this return 0,0,0 as the ambient all during "Daytime," instead of returning the light blue color?
- How could I change this script to make it local, with the time still the same across all clients?
Thank you for your time.
