Script not changing brightness

Hi, i made this script for my game and i think it has no bugs, altough there is this small bug. it doesnt change back the brightness and the atmosphere… my question is: is there something wrong with my script or is it a roblox issue/bug?

Heres the script:

local button = script.Parent
local atmosphere = game.Lighting.Atmosphere
local cloud = game.Workspace.Terrain.Clouds
local DOF = game.Lighting.RainDepthOfField
local brightness = game.Lighting.Brightness

local rain1 = game.Workspace.Map.Aesthetics.Rain.Rain1.Rain
local rain2 = game.Workspace.Map.Aesthetics.Rain.Rain2.Rain
local rain3 = game.Workspace.Map.Aesthetics.Rain.Rain3.Rain
local rain4 = game.Workspace.Map.Aesthetics.Rain.Rain4.Rain
local rain5 = game.Workspace.Map.Aesthetics.Rain.Rain5.Rain
local rain6 = game.Workspace.Map.Aesthetics.Rain.Rain6.Rain
local rain7 = game.Workspace.Map.Aesthetics.Rain.Rain7.Rain
local rain8 = game.Workspace.Map.Aesthetics.Rain.Rain8.Rain
local rain9 = game.Workspace.Map.Aesthetics.Rain.Rain9.Rain
local rain10 = game.Workspace.Map.Aesthetics.Rain.Rain10.Rain



button.MouseButton1Click:Connect(function()
	local allRainEnabled = rain1.Enabled and rain2.Enabled and rain3.Enabled and rain4.Enabled and rain5.Enabled and rain6.Enabled and rain7.Enabled and rain8.Enabled and rain9.Enabled and rain10.Enabled

	if not allRainEnabled then
		rain1.Enabled = true
		rain2.Enabled = true
		rain3.Enabled = true
		rain4.Enabled = true
		rain5.Enabled = true
		rain6.Enabled = true
		rain7.Enabled = true
		rain8.Enabled = true
		rain9.Enabled = true
		rain10.Enabled = true
		
		button.Text = "Rain: On"
		atmosphere.Density = 0.6
		cloud.Cover = 0.7
	    DOF.Enabled = true
		game.Lighting.brightness = 0.3
	else
		rain1.Enabled = false
		rain2.Enabled = false
		rain3.Enabled = false
		rain4.Enabled = false
		rain5.Enabled = false
		rain6.Enabled = false
		rain7.Enabled = false
		rain8.Enabled = false
		rain9.Enabled = false
		rain10.Enabled = false
		
		button.Text = "Rain: Off"
		atmosphere.Density = 0.6
		cloud.Cover = 0.5
		DOF.Enabled = false
		game.Lighting.Brightness = 3
		
	end
end)

(Idk if this is the right topic tho)

1 Like

I recommend using your own variable of true and false instead of checking if all of them are enabled and then toggling that on and off when you click the button. Then toggle the state of rain based on the variable.

1 Like

thx for the advice! but do you have any idea why the brightness part of the script is not working?

1 Like

You forgot to capitalize the “B” in “brightness”

1 Like

thx sm! this seems to solve the problem!!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.