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

How to make a lightswitch?

Asked by 9 years ago

I want to click in a part and whean I click it, I want another part to light. I'm kinda noob with scripting so can someone help me?

1 answer

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

Put a ClickDetector inside of the Part and this script as a descendant of the Part as well. Make sure it's a PointLight. If not, I'm sure you can modify this.

on = false
script.Parent.ClickDetector.MouseClick:connect(function()
    if on == false then
        on = true
        script.Parent.PointLight.Enabled = true
    else
        on = false
        script.Parent.PointLight.Enabled = false
    end
end)
0
Thank you very much, I didn't wanted to click in the light to turn it on and off, I wanted to click in an interrupter so it can turn the light on and off, but I changed some things in the script you send and it works :D Thanks a lot! JohnyCruz 14 — 9y
0
Glad I could help Shawnyg 4330 — 9y
Ad

Answer this question