I made a light switch that controls only one light, here is the script used:
switch = script.Parent light = game.Workspace.LIGHT.PointLight switch.ClickDetector.MouseClick:connect (function() if light.Enabled == false then light.Enabled = true switch.BrickColor = BrickColor.new("Lime green") elseif light.Enabled == true then light.Enabled = false switch.BrickColor = BrickColor.new("Really red") end end)
How do I make more than one light turn on but with only using the one light switch? (I need 6 PointLight blocks to turn on with only one light switch on the wall)
You can put all of the PointLight object parts into a single model and then use a For loop to turn each one on. Here is the For loop that you would need to use:
switch = script.Parent switch.ClickDetector.MouseClick:connect (function() for i, v in pairs(game.Workspace.MODELNAME:GetChildren()) do if v.PointLight.Enabled == true then v.PointLight.Enabled = false switch.BrickColor = BrickColor.new("Really red") else v.PointLight.Enabled = true switch.BrickColor = BrickColor.new("Lime green") end wait() end end)