local LightOn = false
local Light = script.Parent.Parent
script.Parent.ClickDetector.MouseClick:connect(function()
if LightOn then
LightOn = false
Light.children.Transparency = 1
else
LightOn = true
Light.children.Transparency = 0
end
end)
By using the variable "LightOn", the script will alternate between on and off every time that you click, and manage the light based on the value. I presume "children" is the name of the part, and you didn't mean "GetChildren()", in which case I'd use this code:
local LightOn = false
local Light = script.Parent.Parent
Alternate = function(Trans)
for _,Part in pairs(Light:GetChildren()) do
Part.Transparency = Trans
end
end)
script.Parent.ClickDetector.MouseClick:connect(function()
if LightOn then
LightOn = false
Alternate(1)
else
LightOn = true
Alternate(0)
end
end)