Problem with while loop changing materials

Shorthand: https://i.gyazo.com/b3ed7c388f88fe9865384e896f10ace6.mp4

Longhand: I’m making an ELS system for a fire crossing, where if you press a button, the lights consecutively flash after the other.

image

I think you can figure out which ones EMLightBottom, EMLightTopLeft and EMLightTopRight are.

local Event = game.ReplicatedStorage:FindFirstChild("FireAlarm")

local sp = script.Parent
local Lights = sp.Lights

local LightDisabled = true

local function enableLights()
	while LightDisabled == false do
		Lights.EMLightTopRight.Light.Material = Enum.Material.Neon
		Lights.EMLightTopLeft.Light.Material = Enum.Material.SmoothPlastic
		wait(0.75)
		Lights.EMLightTopRight.Light.Material = Enum.Material.SmoothPlastic
		Lights.EMLightTopLeft.Light.Material = Enum.Material.Neon
		wait(0.75)
	end
end

Event.Event:Connect(function()
	if LightDisabled then 
		LightDisabled = false
		Lights.EMLightBottom.Light.Material = Enum.Material.SmoothPlastic
		enableLights()
	else
		if LightDisabled == false then
			LightDisabled = true
			Lights.EMLightBottom.Light.Material = Enum.Material.Neon
			Lights.EMLightTopRight.Light.Material = Enum.Material.SmoothPlastic
			Lights.EMLightTopLeft.Light.Material = Enum.Material.SmoothPlastic
		end
	end
end)

The problem is that when I toggle the lights while EmLightTopRight is “on”, then the loop returns once more and sets EmLightTopLeft‘s material to Neon, as shown in the video. I want both of the lights’ materials to be set to SmoothPlastic, and EmLightBottom's material set to SmoothPlastic when I deactivate it.

local function enableLights()
	while LightDisabled == false do
		Lights.EMLightTopRight.Light.Material = Enum.Material.Neon
		Lights.EMLightTopLeft.Light.Material = Enum.Material.SmoothPlastic
		wait(0.75)
		Lights.EMLightTopRight.Light.Material = Enum.Material.SmoothPlastic
		Lights.EMLightTopLeft.Light.Material = Enum.Material.Neon
		wait(0.75)
	end
    Lights.EMLightTopRight.Light.Material = Enum.Material.SmoothPlastic
    Lights.EMLightTopLeft.Light.Material = Enum.Material.SmoothPlastic
end

You are already checking to see if LightsDisabled is false. If it’s true that loop will stop running then the rest of the function will run, making both lights SmoothPlastic.