✓ Accepted answer
Sure, So I'm assuming you're probably using a PointLight with the Enabled Property set as true (for on) or false for off.
If you want to call multiple parts, you pre-define them, such as
local light1 = workspace.Light1.PointLight
local light2 = workspace.Light2.PointLight
local light3 = workspace.Light3.PointLight
then write a function like the one below
workspace.Switch1.ClickDetector.MouseClick:Connect(function()
if light1.Enabled == false then
light1.Enabled = true
light2.Enabled = true
light3.Enabled = true
elseif light1.Enabled == true then
light1.Enabled = false
light2.Enabled = false
light3.Enabled = false
end
end)
Combined
local light1 = workspace.Light1.PointLight
local light2 = workspace.Light2.PointLight
local light3 = workspace.Light3.PointLight
workspace.Switch1.ClickDetector.MouseClick:Connect(function()
if light1.Enabled == false then
light1.Enabled = true
light2.Enabled = true
light3.Enabled = true
elseif light1.Enabled == true then
light1.Enabled = false
light2.Enabled = false
light3.Enabled = false
end
end)
You can also define them within the function if you wanted to
workspace.Switch1.ClickDetector.MouseClick:Connect(function()
if workspace.Light1.PointLight.Enabled == false then
workspace.Light1.PointLight.Enabled = true
workspace.Light2.PointLight.Enabled = true
workspace.Light3.PointLight.Enabled = true
elseif workspace.Light1.PointLight.Enabled == true then
workspace.Light1.PointLight.Enabled = false
workspace.Light2.PointLight.Enabled = false
workspace.Light3.PointLight.Enabled = false
end
end)
EDIT: I'll append the script you added using the information above:
local detector = script.Parent.ClickDetector
local light1 = workspace.Light.Light
local model = workspace.Isw1
detector.MouseClick:Connect(function()
if light1.PointLight.Enabled == false then
light1.PointLight.Enabled = true
light1.Material = "Neon"
model.Union.Transparency = 1
model.ls2.Transparency = 0
else
light1.PointLight.Enabled = false
light1.Material = "Plastic"
model.Union.Transparency = 0
model.ls2.Transparency = 1
end
end)
5 comments
To explain how to do it, you more or less have to make the script.. do you have one that works for a single switch already so we can help show you what to change?
just added it
Put every lightswitch in a table, and loop through each of them and if theyre off then turn them on
Put every lightswitch in a table, and loop through each of them and if theyre off then turn them on
Sir it's been seven days, has any of our answers worked?