game.Workspace.Lamp.Bulb.SpotLight.Range = light light = 0 function onClicked()
if light == 0 then light = 1
end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
✓ ANSWER ACCEPTED
Why won't the function change the light values?
1 answer
✓ Accepted answer
First of all, you seem to have the first variable the opposite way around (the variable name should come before the equal sign, and the value after):
local light = game.Workspace.Lamp.Bulb.SpotLight.Range
The other problem is that, when using value objects, you have to make sure to include .Value every time you read from/write to that value:
if light.Value == 0 then
light.Value = 1
end
Hope this helps!
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Sorry the formatting is doodoo