Outdoor Ambient Changing Script Not Working?

I am trying to change the outdoor ambient at different times of the day, but when it gets to that time it does not change? i have also tried elseif , but that didn’t work.

while true do
	wait(1)
	if game.Lighting.TimeOfDay >= "17:00:00" then
game.Lighting.OutdoorAmbient = Color3.fromRGB(226, 211, 1)  

if game.Lighting.TimeOfDay >= "17:47:59" then
game.Lighting.OutdoorAmbient = Color3.fromRGB( 128, 128, 128)   

if game.Lighting.TimeOfDay >= "19:00:00" then
	game.Lighting.OutdoorAmbient = Color3.fromRGB(0, 40, 120) 

if game.Lighting.TimeOfDay >= "06:12:00" then

game.Lighting.OutdoorAmbient = Color3.fromRGB(189, 173, 0)

	if game.Lighting.TimeOfDay >= "07:30:00" then
		game.Lighting.OutdoorAmbient = Color3.fromRGB(128, 128, 128)
end
end
end
end
end
end
2 Likes

You are attempting to use number operators on a string value. Use game.Lighting:GetMinutesAfterMidnight() to achieve this.

I am on mobile so I hate typing out code lol

2 Likes

oh ok would i need to change the time of day number for get minutes after midnight? like would i need to change 07:00:00

What do you mean? Like instead of “17:00:00” change it to 1020? Then yes you do.

1 Like

yes thank you that is what i was wondering

1 Like

You are welcome! Happy to help.

1 Like

i think i still typed it wrong… would i need to remove the if?

if game.Lighting:GetMinutesAfterMidnight(1020) then

game.Lighting.OutdoorAmbient = Color3.fromRGB(226, 211, 1)

You are passing 1020 as an argument for :GetMinutesAfterMidnight(). GMAM only returns a value. Use GMAM like so:

if game.Lighting:GetMinutesAfterMidnight() > 1020 then
     game.Lighting.OutdoorAmbient = Color3.fromRGB(266, 211, 1)
end