0

# On/Off Button Lantern?

I need help with this. I tinkered around with a free model (mainly for learning how coding works) and it isn't working. What is wrong here?

mylight = game.Workspace.Lamp.Lamp.ButtonLight.PointLight
function click()
mylight.Enabled = not mylight.Enabled
end


Anyways, the output suggests putting a '=' sign by Function. Its not working. the 2nd line is the only problem. This is for a lantern with a clickable on/off button.

0
KarlXYZ 120
6 years ago

This probably isn't the most efficient way to deal with your issue, but it should still work fine.

Just replace this with your current function.

function click()
if mylight.Enabled == true then
mylight.Enabled = false
else if mylight.Enabled == false then
mylight.Enabled = true
end
end
end

--Edit ButtonPathHere with the path leading to your on/off button.