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

How can I get my ambient script to work correctly?

Asked by 8 years ago

So, I have a script that changes the Outdoor Ambient depending on the time of day. When it's dark out, the ambient is 0,0,0, at dawn it has a bluish hue, etc.

The following script is almost a year old, from one of my PAs that had a Scripting Helpers account. It worked for me a year ago, IDK why it isn't working now. I changed it from FogColor to OutdoorAmbient, if that means anything.

game.Lighting.Changed:connect(function()
    if game.Lighting.TimeOfDay == "00:00:00" then
        game.Lighting.OutdoorAmbient = Color3.new(0,0,0)
    elseif game.Lighting.TimeOfDay == "5:00:00" then
        game.Lighting.OutdoorAmbient = Color3.new(13/255,60/255,131/255)
    elseif game.Lighting.TimeOfDay == "7:00:00" then
        game.Lighting.OutdoorAmbient = Color3.new(127/255,127/255,127/255)
    end
end)

The script doesn't work though, and I'm starting my game at midnight, which should have 0,0,0 as an outdoor ambient. When I run the game, it stays at 127,127,127 as normal.

If any of you could tell me what I'm doing wrong, that would be much appreciated. :)

0
Are you ever changing the TimeOfDay property? It doesn't change on its own. BlackJPI 2658 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

You have that under the Changed event, but you aren't changing lighting. You should fire that function when the game starts, so do something like this:

function ambientChange()
    <youcodehere>
end

game.Lighting.Changed:connect(ambientChange())

ambientChange()
Ad

Answer this question