How to make Script reference multiple Models in Workspace?

@yoshicoolTV
PowerOutageSystem.rbxm (55.2 KB)

I just Updated the Kit here it is:
PowerOutageSystem.rbxm (52.5 KB)

The while true loop will yield the thread you’ll need to spawn each of the while loops in a new thread

for i, v in pairs(workspace.Lights:GetDescendants()) do
	if v:IsA("Model") and v.Name == "LightBulb" then
		task.spawn(function()
			while true do
				local randomnumber = wait(math.random(5, 7))
				print(randomnumber)
				---------------------------------------------------------------------------------
				game.Lighting.Atmosphere.Density = 1
				game.Lighting.Atmosphere.Haze = 10
				script.PowerOff:Play()
				script.PowerOn:Play()

				local randomnumber = wait(math.random(9, 20))
				print(randomnumber)
				script.PowerOn:Play()
				script.PowerOff:Stop()
				v.Bulb.PointLight.Brightness = 1
				v.Light.Transparency = 0
				game.Lighting.Atmosphere.Density = 0
				game.Lighting.Atmosphere.Haze = 0
			end
		end)
	end
end

Your Script is good but it is missing an important function the Light Brightness must set to 0 when the Power is (Off) and when the Power is (On) Light Brightness is set to 1.

@Indominiso
I also realized there is a 2 second delay between the Turn (On) and Turn (Off) function

ezgif-2-b510492b09