0

# Trying to toggle all alarms from a button, not working with no errors?

This button I'm making is supposed to toggle on and off all of the spinning lights. There are no errors, but the ")" on the last "end" is red, and when i delete it, some of the script becomes underlined red too.

local button = script.Parent.ClickDetector -- your little button
local lights = game.Workspace.Lights:GetDescendants() -- your light
local lights_are_on = false -- take a boolean value for the state of the light

button.MouseClick:connect(function()  -- Assuming that you have setup the Click Detector
for i, v in pairs (lights) do
if v:IsA("SpotLight") then
if not lights_are_on then -- check if the lights are on or not on
lights.Enabled = true --  if they are not on, turn them on!
lights_are_on = true -- Don't forget to check out litttle boolean that helps us alot!
elseif lights_are_on then
lights.Enabled = false--  if they are on, turn them off!
lights_are_on = false -- so we know that they are off
end
end)


0
vra000 22
4 days ago

local button = script.Parent.ClickDetector -- your little button local lights = game.Workspace.Lights:GetDescendants() -- your light local lights_are_on = false -- take a boolean value for the state of the light

button.MouseClick:connect(function()  -- Assuming that you have setup the Click Detector
for i, v in pairs (lights) do
if v:IsA("SpotLight") then
if not lights_are_on then -- check if the lights are on or not on
lights.Enabled = true --  if they are not on, turn them on!
lights_are_on = true -- Don't forget to check out litttle boolean that helps us alot!
elseif lights_are_on then
lights.Enabled = false--  if they are on, turn them off!
lights_are_on = false -- so we know that they are off
end
end
end)

0
still doesnt work TheStarWarsMaster856 16 — 3d