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

Help with scripting a light?

Asked by 10 years ago

Hi,

I want to make a button that does two jobs. I press is once and it turns on the light, I press it again and it turns it off.

I have a blank script in the button with a click detector in the button as well.

This is the link from the script to the light

script.Parent.Parent.SpotLight1.Light.SpotLight

What would the script be so I can turn it on and off with the one button!?

Thanks Kieran

3 answers

Log in to vote
0
Answered by
KAAK82 16
10 years ago

easy... say this is the Light Model;

Light Model<

LightModel<< -LightPart --PointLight

ButtonModel<< -Button --ClickDetector -Script

LP = script.Parent.Parent.LightModel.LightPart.PointLight
btn = script.Parent.Button.ClickDetector

function onClick()
if LP.Enabled == true then
LP.Enabled = false
else
LP.Enabled = true

btn.MouseClick:connect(onClick)
0
I have used this script with my in put into this, what am I doing wrong? kieranm9090 49 — 10y
0
LP = script.Parent.Parent.SpotLight1.Light.PointLight btn = script.Parent.ClickDetector function onClick() if LP.Enabled == true then LP.Enabled = false else LP.Enabled = true btn.MouseClick1:connect(onClick) end end kieranm9090 49 — 10y
0
lemme see... well 1st try see if there are any red lines (errors) then check the output... KAAK82 16 — 10y
0
Nope, there arn't any kieranm9090 49 — 10y
View all comments (2 more)
0
It's ok now I have managed to configure it. Thanks kieranm9090 49 — 10y
0
np, sry I couldn't respond to help faster though... KAAK82 16 — 10y
Ad
Log in to vote
0
Answered by 10 years ago
LP = script.Parent.Parent.SpotLight1.Light.PointLight
btn = script.Parent.ClickDetector

function onClick()
if LP.Enabled == true then
LP.Enabled = false
else
LP.Enabled = true

btn.MouseClick1:connect(onClick)

end
end

Log in to vote
-1
Answered by 10 years ago

This is not a request site.

Answer this question