Flashing Light Not Working?

I am trying to make a lightning flash, there are no errors in the output, but the flash never comes

I am not sure what I did wrong in my script here:

wait(.1)

local light = game:GetService("Lighting")
local flash = light.ColorCorrection.Brightness

while wait(math.random(1,10)) do

flash = 1
wait(1)
flash = 0
script.Thunder.Playing = true

end

this script is located in the Workspace, I’m not sure whats wrong :confused:
Thank you for your time!

A few things,

Your flash variable will never change the Brightness as it stores the value Brightness was set to when the variable was initialized, you need to make flash be light.ColorCorrection

Secondly, I would recommend you do script.Thunder:Play() instead of script.Thunder.Playing = true as that is how it’s normally done to play sounds

All in all, I think the code sohudl be liek this inorder for it to work

local light = game:GetService("Lighting")
local flash = light.ColorCorrection

while wait(math.random(1,10)) do
	flash.Brightness = 1
	wait(1)
	flash.Brightness = 0
	script.Thunder:Play()
end

Although something could be correct as I did not ask for any other information like the type of script it is and what not, but this should work

1 Like

Thank you, it worked perfectly!

1 Like

Anytime! If you have anymore issue sdon’t be afraid to make another post!