Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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

0
OutdoorAmbient requires a new Color3 object each time e.g. game.Lighting.OutdoorAmbient = Color3.new(135/255, 135/255, 128/255) User#5423 17 — 7y
0
The r, g, b of a Color3 object are read only http://wiki.roblox.com/index.php?title=Color3#Properties User#5423 17 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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.

Ad

Answer this question