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