Lighting brightness can not be changed back to the default

if I try to reset the brightness back to the old one after I changed it, it won’t do anything.

--Example if the default is "3"
while true do
game.Lightning.Brightness = 1
wait(1)
game.Lightning.Brightness = 3
end

The brightness value stays on “3” after running the code. (I simplified what I’m doing since mine gives around the same result as running this code.)

You are forgetting to add a wait() at the end,
so right after the Brightness turns to 3, it goes back to 1

Should fix it:

while true do
game.Lighting.Brightness = 1
wait(1)
game.Lighting.Brightness = 3
wait(1)
end

Yep:

There is a spelling error in the code you posted.

Check Lightning vs. Lighting.

1 Like

Or

while true do
  game:GetService("Lighting").Brightness = 1
  task.wait(1)
  game:GetService("Lighting").Brightness = 3
  task.wait(1)
end

:stuck_out_tongue_closed_eyes:

@frrazers
game:GetService() is useless to add as it is not attempting to get a Service but a child

1 Like

Fair enough then, would still use task.wait() though

I accidently made a writing error in the example script. Here is my real code.

game.Lighting.Brightness = 3.1

after running this for the second one it will no longer work (I’m using 3.1 instead of the default I have set of 3 due to it otherwise not changing)

is there any difference between task.wait() and wait()?

wait() is deprecated, task.wait() is the newer updated version

2 Likes

wait() runs 30 frames within a Second, with means the fastest it can go is 0.03 Seconds

task.wait() runs exactly on each frame (I believe)

Example: (The Fastest one is task.wait())


Scuffed Camera angle LOL

1 Like

in the code I’m using where I activate a proximityprompt twice adding in a delay doesn’t do anything.
Example code:

script.Parent.V.Triggered:Connect(function()
task.wait(0.1)
	game.Lighting.Brightness = 3.1
end)
script.Parent.V.Triggered:Connect(function()
task.wait()
	game.Lighting.Brightness = 3.1
end)

For the record. After activating this code

script.Parent.V.Triggered:Connect(function()
	game.Lighting.Brightness = 1
end)

and then activating this code

script.Parent.V.Triggered:Connect(function()
	game.Lighting.Brightness = 3.1
end)

and then doing this twice the value will not be changed back to 3.1

i hope you understand you showed a while loop, not a ProximityPrompt