wait(1) local act = _G.actvalue -- The global value local inuse = false -- This is neccecary only for the script to not break and stuff, this needs to remain false. _G["ALightsToggled"] = true function alarmchange(alert) if not inuse then inuse = true if _G.actvalue == "Inactive" then local c = script.Parent:GetChildren() for i = 1, #c do if c[i].Name == "LightPart" then if c[i]:FindFirstChild("PointLight") ~= nil then c[i].PointLight.Brightness = 1 elseif c[i]:FindFirstChild("SpotLight") ~= nil then c[i].SpotLight.Brightness = 1 elseif _G.actvalue == "Red" then local c = script.Parent:GetChildren() for i = 1, #c do if c[i].Name == "LightPart" then if c[i]:FindFirstChild("PointLight") ~= nil then c[i].PointLight.Brightness = 0.4 elseif c[i]:FindFirstChild("SpotLight") ~= nil then c[i].SpotLight.Brightness = 0.4 end end end end end _G["AToggleLights"] = function() if _G["ALightsToggled"] == true then local c = script.Parent:GetChildren() for i = 1, #c do if c[i].Name == "LightPart" then if c[i]:FindFirstChild("PointLight") ~= nil then c[i].PointLight.Enabled = true c[i].BrickColor = BrickColor.new(226) elseif c[i]:FindFirstChild("SpotLight") ~= nil then c[i].SpotLight.Enabled = true c[i].BrickColor = BrickColor.new(226) end end end elseif _G["ALightsToggled"] == false then local c = script.Parent:GetChildren() for i = 1, #c do if c[i].Name == "ALightPart" then if c[i]:FindFirstChild("PointLight") ~= nil then c[i].PointLight.Enabled = false c[i].BrickColor = BrickColor.new(1003) elseif c[i]:FindFirstChild("SpotLight") ~= nil then c[i].SpotLight.Enabled = false c[i].BrickColor = BrickColor.new(1003) end end end end end
It seems that you have the incorrent amount of 'ends' needed. Quick Fix:
function alarmchange(alert) if not inuse then inuse = true if _G.actvalue == "Inactive" then local c = script.Parent:GetChildren() for i = 1, #c do if c[i].Name == "LightPart" then if c[i]:FindFirstChild("PointLight") ~= nil then c[i].PointLight.Brightness = 1 elseif c[i]:FindFirstChild("SpotLight") ~= nil then c[i].SpotLight.Brightness = 1 elseif _G.actvalue == "Red" then local c = script.Parent:GetChildren() for i = 1, #c do if c[i].Name == "LightPart" then if c[i]:FindFirstChild("PointLight") ~= nil then c[i].PointLight.Brightness = 0.4 elseif c[i]:FindFirstChild("SpotLight") ~= nil then c[i].SpotLight.Brightness = 0.4 end end end end end end end end end