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

Trying to change Ambient in Lighting, but it isn't working?

Asked by 8 years ago

For a 'disaster' style game I am making I need to change the ambient lighting to white so people can see. The reason I want to change it with a script is because it is Halloween themed and it needs to be creepy in the spawn. When the 'disaster' is selected, I want the ambient to change to white so people can actually see in the other maps where the shadows are not really required for the full effect of the scariness. The wait(17) is the time it takes for the game to select the 'disaster' and the wait(180) is how long the 'disaster' lasts. So what did I do wrong here? I am still a beginner level scripter so I seem to need help with all the basic level scripts haha.

local Ambient = game.Lighting.Ambient

while true do
    wait(17)
    Ambient = Color3.new(255, 255, 255)
    wait(180)
    Ambient = Color3.new(0, 0, 0)
end

2 answers

Log in to vote
0
Answered by 8 years ago
while true do
    wait(17)
    game.Lighting.Ambient = Color3.new(1, 1, 1)
    wait(180)
    game.Lighting.Ambient = Color3.new(0, 0, 0)
end

As seen in the above code, Color3s only go to 1,1,1, which is completely white, and 0,0,0, which is completely black. The Color3s you see in the Properties window are not the actual R, G, and B values.

0
Didn't quite catch that one! IDidMakeThat 1135 — 8y
0
Perfect. That worked brilliantly. Thank you so much! Malefactus 55 — 8y
Ad
Log in to vote
1
Answered by 8 years ago

The problem is that if you try to set a variable's value to a property (in this case the Ambient property of Lighting) it will set it to the value contained within the property, rather than a reference to it. To fix it:

local Lighting = game.Lighting

while true do
    wait(17)
    Lighting.Ambient = Color3.new(255, 255, 255)
    wait(180)
    Lighting.Ambient = Color3.new(0, 0, 0)
end

0
Nope TerrodactyI 173 — 8y
0
Nope. This just made the entire screen white. So instead of everything being pitch black, this makes the entire screen white so I still cant see anything. Thanks for posting though. Malefactus 55 — 8y

Answer this question