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

Why won't the lighting brightness change with my script?

Asked by 5 years ago

It says it all in the title. No errors in the output when I run the script

-- Made by Cakeymasterluke

local brightness  = game.Lighting.Brightness

while true do
    wait(3)
    brightness = 1.9
    wait(.125)
    brightness = 1.8
    wait(.125)
    brightness = 1.7
    wait(.125)
    brightness = 1.6
    wait(.125)
    brightness = 1.5
    wait(.125)
    brightness = 1.4
    wait(.125)
    brightness = 1.3
    wait(.125)
    brightness = 1.2
    wait(.125)
    brightness = 1.1
    wait(.125)
    brightness = 1
end

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Brightness is a property of Lighting (a UserData object), not an object itself, so you can't make a Lua variable reference to it. Your script is reading game.Lighting.Brightness into the variable brightness, but then only the variable's value ever gets changed, never the property of Lighting.

If you just replace brightness with game.Lighting.Brightness everywhere you set it, you will see it change. You can also make a variable reference to game.Lighting, just not to one of its properties.

Ad

Answer this question