Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I change the Outdoor Ambient according to the time in the game?

I have tried over and over again but failed constantly, I need help with this.. The text after this message is my code

local MinutesAfterMidnight = 0

while true do

game.Lighting:SetMinutesAfterMidnight(MinutesAfterMidnight)
MinutesAfterMidnight = MinutesAfterMidnight + 1
wait (0.01)

if MinutesAfterMidnight >= 6 * 60 and MinutesAfterMidnight <= 18 * 60 then
	game.Lighting.Brightness = (1)
	game.Lighting.OutdoorAmbient.r = (0/255)
	game.Lighting.OutdoorAmbient.g = (0/255)
	game.Lighting.OutdoorAmbient.b = (0/255)
end
if MinutesAfterMidnight >= 18 * 60 and MinutesAfterMidnight <= 6 * 60 then 
	game.Lighting.Brightness = (0)
	game.Lighting.OutdoorAmbient.r = (135/255)
	game.Lighting.OutdoorAmbient.g = (135/255)
	game.Lighting.OutdoorAmbient.b = (128/255)
end	

end

2 comments

0

OutdoorAmbient requires a new Color3 object each time e.g. game.Lighting.OutdoorAmbient = Color3.new(135/255, 135/255, 128/255)

0

The r, g, b of a Color3 object are read only http://wiki.roblox.com/index.php?title=Color3#Properties

1 answer

Additional to kingdom5's comment: a value can't be bigger than 18x60 and lower than 6x60(Describing the second if condition) so use or instead of and for it and it will take care of your script.

Note: and in first if condition is fine, don't change it.

This discussion is preserved as it was. New answers, comments, and votes are closed.