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
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, Color3
s only go to 1,1,1
, which is completely white, and 0,0,0
, which is completely black. The Color3
s you see in the Properties window are not the actual R, G, and B values.
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