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

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

Asked by 7 years ago

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

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

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)
0
Still will not work, I am using a point light. iiGardenAviator 5 — 7y
0
It will work now. chia_pet 24 — 7y
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! iiGardenAviator 5 — 7y
0
You're welcome! chia_pet 24 — 7y
Ad

Answer this question