Hello everyone I have a problem that I do not understand, my goal is to change the properties “Ambient” and “OutDoorAmbient” depending on the time of day. I watched the other posts about this topic but nothing works, I really can not understand why my script does not work.
I hope someone could help me thank you in advance.
The Script:
minute = game.Lighting:GetMinutesAfterMidnight()
while true do
game.Lighting:SetMinutesAfterMidnight(game.Lighting:GetMinutesAfterMidnight()+ 1)
wait(0) --1 min = 4,778761062
end
while true do
if game.minute >= 360 then
game.Lighting.Ambient = Color3.fromRGB (70,70,70)
game.Lighting.OutdoorAmbient = Color3.fromRGB(84,84,84)
wait()
end
if game.minute >= 420 then
game.Lighting.Ambient = Color3.fromRGB (106,106,106)
game.Lighting.OutdoorAmbient = Color3.fromRGB(138,138,138)
wait()
end
if minute >= 1020 then
game.Lighting.Ambient = Color3.fromRGB (106,106,106)
game.Lighting.OutdoorAmbient = Color3.fromRGB(138,138,138)
wait()
end
if minute >= 1080 then
game.Lighting.Ambient = Color3.fromRGB (70,70,70)
game.Lighting.OutdoorAmbient = Color3.fromRGB(84,84,84)
wait()
end
if game.minute >= 1110 then
game.Lighting.Ambient = Color3.fromRGB (38,38,38)
game.Lighting.OutdoorAmbient = Color3.fromRGB(44,44,44)
wait()
end
if game.minute >= 600 then
game.Lighting.Ambient = Color3.fromRGB (150,150,150)
game.Lighting.OutdoorAmbient = Color3.fromRGB(200,200,200)
wait()
end
Hi thank you for responding, I tried to put in the same loop but only one Ambient worked. Or else all Ambient was activated at the same time (with all wait ())
while true do
game.Lighting:SetMinutesAfterMidnight(game.Lighting:GetMinutesAfterMidnight()+ 1)
wait(0) --1 min = 4,778761062
if game.minute >= 360 then
game.Lighting.Ambient = Color3.fromRGB (70,70,70)
game.Lighting.OutdoorAmbient = Color3.fromRGB(84,84,84)
wait()
end
if game.minute >= 420 then
game.Lighting.Ambient = Color3.fromRGB (106,106,106)
game.Lighting.OutdoorAmbient = Color3.fromRGB(138,138,138)
wait()
end
if minute >= 1020 then
game.Lighting.Ambient = Color3.fromRGB (106,106,106)
game.Lighting.OutdoorAmbient = Color3.fromRGB(138,138,138)
wait()
end
if minute >= 1080 then
game.Lighting.Ambient = Color3.fromRGB (70,70,70)
game.Lighting.OutdoorAmbient = Color3.fromRGB(84,84,84)
wait()
end
if game.minute >= 1110 then
game.Lighting.Ambient = Color3.fromRGB (38,38,38)
game.Lighting.OutdoorAmbient = Color3.fromRGB(44,44,44)
wait()
end
if game.minute >= 600 then
game.Lighting.Ambient = Color3.fromRGB (150,150,150)
game.Lighting.OutdoorAmbient = Color3.fromRGB(200,200,200)
wait()
end
You could try removing the waits in each if statement as well. Then just move the wait from the top to the bottom and see if that works (I just can’t see whats wrong). Unless you already got it to work.
Here’s the problem: The Ambient change all at the same time I think it is a problem interval for me but how to fix it?
script:
minute = game.Lighting:GetMinutesAfterMidnight()
coroutine.resume(coroutine.create(function()
while true do
game.Lighting:SetMinutesAfterMidnight(game.Lighting:GetMinutesAfterMidnight()+ 1)
wait(0) --1 min = 4,778761062
end
end))
while true do
if minute >= 360 then
game.Lighting.Ambient = Color3.fromRGB (70,70,70)
game.Lighting.OutdoorAmbient = Color3.fromRGB(84,84,84)
wait()
end
if minute >= 420 then
game.Lighting.Ambient = Color3.fromRGB (106,106,106)
game.Lighting.OutdoorAmbient = Color3.fromRGB(138,138,138)
wait()
end
if minute >= 1020 then
game.Lighting.Ambient = Color3.fromRGB (106,106,106)
game.Lighting.OutdoorAmbient = Color3.fromRGB(138,138,138)
wait()
end
if minute >= 1080 then
game.Lighting.Ambient = Color3.fromRGB (70,70,70)
game.Lighting.OutdoorAmbient = Color3.fromRGB(84,84,84)
wait()
end
if minute >= 1110 then
game.Lighting.Ambient = Color3.fromRGB (38,38,38)
game.Lighting.OutdoorAmbient = Color3.fromRGB(44,44,44)
wait()
end
if minute >= 600 then
game.Lighting.Ambient = Color3.fromRGB (150,150,150)
game.Lighting.OutdoorAmbient = Color3.fromRGB(200,200,200)
wait()
end
You are relying on the variable minute, which was only set one time and not checked again. When you set it to the function it just returned a value, it doesn’t check it again when you call in minute later.