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

Is my scripting correct for this SpotLight?

Asked by 9 years ago

So I'm new to scripting ( editing scripts :) ) and I'm trying to get a dynamic SpotLight to have a button to turn it on and off.

The parts to the light are as follows:

Workspace - Light -- LightState -- Lamp --- Mesh --- SpotLight - Lightsocket -- Part --- Mesh - Switch -- ClickDetector -- Script

The script is as follows:

--Working lightswitch.

function ToggleLight() if script.Parent.LightState.Value == false then script.Parent.LightState.Value = true script.Parent.Light.SpotLight.Enabled = true else script.Parent.LightState.Value = false script.Parent.Light.SportLight.Enabled = false end end

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

I don't know if I have enough Parents, or too many, or if something is not in the right order/spelt incorrectly.

Thanks, Harry

P.S. Sorry if tags are wrong, out of my depth here :]

1 answer

Log in to vote
0
Answered by 9 years ago

Please use the Code Block tab in your writing. It's the button that says "Lua".

Ad

Answer this question