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

Help needed to make a light switch to change every light in game?

Asked by 7 years ago
Edited 7 years ago

I am making a technology wing that has 4 generators, the generator are gonna work as when one goes off it dims when two goes off it dims even more, three even more, and four completely off. These generators have a big green button, I have put a click detector on the button and ik how to change a spotlight's brightness "light.spotlight.brightness = #" but I don't know how to select every light in the game. All the lights are in a group but idk how to change the brightness of an entire group. Ty for your help and time ;)

0
If General_Scripter's answer helped you, you should accept it. You both get rep for it. AZDev 590 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

Simply iterate through the group of lights and change the brightness of each like so:

for _,light in pairs(game.Workspace.Lights:GetChildren()) do
    light.SpotLight.Brightness = light.SpotLight.Brightness-0.1
end

Add that to your current script and with a bit of tweaking you can set it up for your game. If you need more help with this or it doesn't work, let me know in the comments with as much detail as possible. Otherwise, accept this as the answer!

0
Ok thank you so much so instead of using setting the brightness variable I just use an operator (-) , didn't know you could do that, also thanks for the :GetChildren didn't know that was a thing :) Anonymous9201 2 — 7y
Ad

Answer this question