Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't the function change the light values?

Asked by 5 years ago

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)

0
Sorry the formatting is doodoo Swatman5576 2 — 5y

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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!

Ad

Answer this question