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

Click Dector Lights

Asked by 10 years ago

I have made a police bar with working lights now i need a script that can turn of and on the lights with a button the the back of the lights. Please help me .

2 answers

Log in to vote
1
Answered by
MunimR 125
10 years ago
script.Parent.MouseDetector.MouseClick:connect(function()  --Use the MouseClick event on click detectors to detect when the part is clicked on
    script.Parent.SpotLight.Enabled=not script.Parent.SpotLight.Enabled --This flips the SpotLight's enabled property, so if off clicking on it will turn it on vice versa
end)  --ending the function
Ad
Log in to vote
-1
Answered by
Kratos232 105
10 years ago

Here's the script... It's kinda long, because I was too tired to think of a faster one. Basically, it just checks if the light is on then turns it off and vice versa.

Light = script.Parent.SpotLight

script.Parent.MouseDetector.MouseClick:connect(function()
    script.Parent.SpotLight
    if Light.Enabled then
        Light.Enabled = false
    else
        Light.Enabled = true
    end
end)

Well, enjoy. I hope it works, because I hardly use ClickDetectors. I use SurfaceGui's.

  • Kratos232

Answer this question