Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I am trying to make lights turn on after I click a part the second time?

I have already used remote events to turn off the lights with the first click, but how do I turn them back on with a second click?

Here is the local script I put in StarterCharacterScripts ~~~~~~~~~~~~~~~~~

local trigger = game.Workspace.Trigger local clickDetector = trigger.ClickDetector local rep = game.ReplicatedStorage clickDetector.MouseClick:Connect(function() rep.LightsOff:FireServer()

end)

Here is the script that is receiving the event ~~~~~~~~~~~~~~~~~
local rep = game.ReplicatedStorage
rep.LightsOff.OnServerEvent:Connect(function()
	script.Parent.PointLight.Enabled = false
end)


1 answer

✓ Accepted answer

This should work! If it doesn't let me know! (I know there are more efficient ways but this is simple and should work)

local rep = game.ReplicatedStorage
rep.LightsOff.OnServerEvent:Connect(function()
	if script.Parent.PointLight.Enabled == false then
		script.Parent.PointLight.Enabled = true
	else
		script.Parent.PointLight.Enabled = false
	end
end)

2 comments

0

It does work, thanks man!

0

For sure! Glad I could help :)

This discussion is preserved as it was. New answers, comments, and votes are closed.