Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 1 year ago

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

Log in to vote
0
Answered by 1 year ago

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)

0
It does work, thanks man! ENERGYSAVERNANO 14 — 1y
0
For sure! Glad I could help :) ElongatedMongoose 138 — 1y
Ad

Answer this question