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 :]
