So I have a script that changes how dark it is outside, but I would like for it to gradually get dark outside, rather than have it be light one moment and then very dark the next. Is there any way I can do this?
This script controls the time:
while wait (.5) do
game.Lighting:SetMinutesAfterMidnight(game.Lighting:GetMinutesAfterMidnight() +1)
end
And here is the script that changes OutdoorAmbient and FogColor:
b = game.Lighting
local oh,om = 7,00 -- Place gets dark at this time
local ch,cm = 18,30 -- Place becomes light again at this time
local l = game:service("Lighting")
if (om == nil) then om = 0 end
if (cm == nil) then cm = 0 end
function TimeChanged()
local ot = (oh + (om/60)) * 60
local ct = (ch + (cm/60)) * 60
if (ot < ct) then
if (l:GetMinutesAfterMidnight() >= ot) and (l:GetMinutesAfterMidnight() <= ct) then
b.OutdoorAmbient = Color3.fromRGB(135,135,135) -- Morning ambient
b.FogColor = Color3.fromRGB(107,115,93) -- Morning fog
else
b.OutdoorAmbient = Color3.fromRGB(10,10,10) -- Night ambient
b.FogColor = Color3.fromRGB(10,10,10) -- Night fog
end
elseif (ot > ct) then
if (l:GetMinutesAfterMidnight() >= ot) or (l:GetMinutesAfterMidnight() <= ct) then
b.OutdoorAmbient = Color3.fromRGB(135,135,135)
b.FogColor = Color3.fromRGB(107,115,93)
else
b.OutdoorAmbient = Color3.fromRGB(10,10,10)
b.FogColor = Color3.fromRGB(10,10,10)
end
end
end
TimeChanged()
game.Lighting.Changed:connect(function(property)
if (property == "TimeOfDay") then
TimeChanged()
end
end)

1 comment
I'm not sure how to apply this to my script, but surely there's a better way, right?