Hello Developers! I’m trying to make a switch which turn on/off all the lights, but I’m having some problems, I’m going to answer these questions
. What do you want to achieve? Keep it simple and clear!
I want do a switch to turn on/off all the lights.
2. What is the issue? Include screenshots / videos if possible!
The issue is I tried to solve the issues with the code but I can’t, I searched in the Devforum, but I didn’t found any topic related to this specific issue, as I don’t know what is wrong.
3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried to fix the code, but it didn’t work.
I don’t know what is wrong with my code, I just want to do a switch to turn on/off all the lights, I tried to fix it, but it didn’t work, I have a error, but I don’t know why, and I’m unsure if I have more errors.
![]()
RemoteEvents script:
local RemoteEvent = game.ReplicatedStorage.TurnOnOffUpperLights
local RemoteEvent2 = game.ReplicatedStorage.TurnOnOffUpperLights2
local UpperLightsx = script.Parent.Parent.Parent.Parent.UpperLights.Lights
game.ReplicatedStorage.TurnOnOffUpperLights.OnServerEvent:Connect(function ()
RemoteEvent:FireAllClients()
end)
game.ReplicatedStorage.TurnOnOffUpperLights2.OnServerEvent:Connect(function ()
RemoteEvent2:FireAllClients()
end)
Client script:
local ClickDetector = script.Parent.ClickDetector
local parent = script.Parent
local debounce = false
local RemoteEvent = game.ReplicatedStorage.TurnOnOffUpperLights
local UpperLightsx = script.Parent.Parent.Parent.Parent.UpperLights.Lights
local RemoteEvent = game.ReplicatedStorage.TurnOnOffUpperLights
local RemoteEvent2 = game.ReplicatedStorage.TurnOnOffUpperLights2
game.ReplicatedStorage.TurnOnOffUpperLights.OnClientEvent:Connect(function()
for _,Light in pairs(UpperLightsx:GetChildren()) do
Light.Part2.PointLight.Enabled = false
end
end)
game.ReplicatedStorage.TurnOnOffUpperLights2.OnClientEvent:Connect(function()
for _,Light in pairs(UpperLightsx:GetChildren()) do
Light.Part2.PointLight.Enabled = true
end
end)
ClickDetector.MouseClick:Connect(function()
if debounce == false then
debounce = true
parent.Orientation = Vector3.new(60, 90, 0)
RemoteEvent:FireServer ()
elseif debounce == true then
debounce = false
parent.Orientation = Vector3.new(-90, 90, 0)
RemoteEvent2:FireServer ()
end
end)
The error on the output comes from the Client script.
Explorer screenshot:

I hope you can help me.
Kindest regards,
Waum_a.
,