So when i turn on the light it lights up but when i want to turn it off i want to click it again How would i do this? Here is the code
local sp = script.Parent sp.ClickDetector.MouseClick:connect(function() local l = Instance.new("PointLight", script.Parent.Parent.light) l.Brightness = 11 l.Range = 11 l.Shadows = true end) --I just want it to shutoff after i click it agian
I suggest not making one in a script, but putting it there already at script.Parent.Parent.light!
sp.ClickDetector.MouseClick:connect(function() if script.Parent.Parent.light.PointLight.Enabled == false then script.Parent.Parent.light.PointLight.Enabled = true else if script.Parent.Parent.light.PointLight.Enabled == true then script.Parent.Parent.light.PointLight.Enabled = false end)
So what I mean is put one in the part called light.
If helped then accept answer please!
I'm pretty sure CheeseDevie's will work, but this is a more efficient way of doing it (assuming it'll work with a property instead of value) --
sp.ClickDetector.MouseClick:connect(function() script.Parent.Parent.Light.PointLight.Enabled = not script.Parent.Parent.Light.PointLight.Enabled end) -- All it does it sets the point light's enabled value to the opposite of what it currently is.