Problem with Lights Script

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.
image

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:
image

I hope you can help me.

Kindest regards,
Waum_a.

2 Likes

This could help

2 Likes

I think the part of the remotes events is fine, I think it may be other part of the code.

1 Like

Maybe try switching FireServer to FireClient?

1 Like

Well, I want all of the players get the Event.

1 Like

Everybody would get the event. I have a game that uses FireAllClients: OnClientEvent: so that a GUI appears for everybody on the server.

Oh, okay, but is necessary change to FireClient? Or it can be fixed?

Yes, if your question is changing FireServer to FireClient.

Oh, ok, I never used FireClient, can I get an example script, please? I mean, how to use it.
Is it like using OnclientEvent:Connect (function ()?

Yeah thats basically it. You could always refer back to this

if you need any help,

If this did help, please click the Solution button.

1 Like

I’m getting this error: image , image

:FireClient() 

fires to a specific client meaning that you need to put that as the first argument

:FireClient(game.Players.kingerman88)

However you can use

:FireAllClients()

instead

1 Like