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)

1 comment
still doesnt work