Hey everbody, I made a script that would turn on and off a PointLight within the game. Turning it OFF works fine, but turning it on doesn't. It should also change the colour of the switch green while on, and red while off. It turns it red, but doesn't turn it back on, or green. Here is the code. Any help is welcome.
switch=game.Workspace.Light_Switch.LightSwitch
lamp=game.Workspace.LightSource.PointLight
if lamp==nil then
print "lamp does not exist"
else
print "Lamp exists"
end
function onClicked()
if lamp.Enabled==False then
switch.BrickColor=BrickColor.Green()
lamp.Enabled=True
else
lamp.Enabled=False
switch.BrickColor=BrickColor.Red()
end
end
switch.ClickDetector.MouseClick:connect(onClicked)
Thanks for the answer that was given, it however, still does not work. If anybody could help me I would be very grateful.

1 comment
You should definitely tab and space your code correctly.