Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't the function change the light values?

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)

1 comment

0

Sorry the formatting is doodoo

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.