Repeat - Until Loop Help

I am working on a button that flashes, and I am using a Repeat - Until Loop.
And I was wanting it to keep flashing until the button named “Dispatch” has been clicked on.
I am just not sure what to do after “until”, for it to detect you clicking on it and stopping the loop.
Here is the code:

        repeat
			game.Workspace.Dispatch.Material = 'Neon'
			wait(.5)
			game.Workspace.Dispatch.Material = 'Smooth Plastic'
		until

Define a variable before the loop and make it false.
Then update the variable when part is clicked.

local clicked = false

part.ClickDetector.MouseClick:Connect(function()
     clicked = true
end)

Repeat
    game.Workspace.Dispatch.Material = "Neon"
    wait(0.5)
    game.Workspace.Dispatch.Material = "Smooth Plastic"
until clicked
1 Like