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

How can I fix the lighting scripts to make it work on and off?

I am trying to make a First class seat for my airline. The lighting will not work. Here are the scripts.

(To make it off)

function onClicked() script.Parent.Parent.Brightness = 0 script.Parent.Parent.Range = 0 end script.Parent.ClickDetector.MouseClick:connect(onClicked)

(To make it on)

function onClicked() script.Parent.Parent.Brightness = 1 script.Parent.Parent.Range = 8 end script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

✓ Accepted answer

You have to set a debounce. (go here for a further explanation: http://wiki.roblox.com/?title=Debounce)

I apologize, I should have fixed that. Set the script's parent to the Part instead of PointLight, because ClickDetector is not a child of PointLight.

debounce = false

 

script.Parent.ClickDetector.MouseClick:connect(function()

if debounce == false then

script.Parent.PointLight.Brightness = 1

script.Parent.PointLight.Range = 8

debounce = true

 

else

 

script.Parent.PointLight.Brightness = 0

script.Parent.PointLight.Range = 0

debounce = false

end

end)

4 comments

0

Still will not work, I am using a point light.

0

It will work now.

0

Yay it works! I see I did something wrong after you told me that, but then I fixed it. This was very helpful. Definitely will remember debounce again next time I need to light something up. Thanks for the help!

0

You're welcome!

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