local function Blink()
while true do
loopingPart1.BrickColor = BrickColor.new("Really red")
loopingPart2.BrickColor = BrickColor.new("Really red")
wait(0.5)
loopingPart1.BrickColor = BrickColor.new("Smoky grey")
loopingPart2.BrickColor = BrickColor.new("Smoky grey")
wait(0.5)
end
end
print("Blink")
Flash.MouseClick:Connect(Blink)
I want to break it with a Button thats not in the same Model.
I tried to write it myself but it just started repeating the loop and one broke my game.
Am I missing a Step?
Thanks
You could just have a value or variable and set it to false at the start. Then if the button is clicked then you would change the value or variable to true and then in the loop check if the value is true then use the break function thing.
a value wont work because the button that flashes has to turn red permernently when its clicked by another Button which ahs to break the Loop.
So i Dont know how to do this. I have my loop and its works fine but how does the loop know now that wehn i press the Button that i want the loop to end and then the button to turn red Permanently?
it switches really red an ghost grey and it only switched to really red when the button is pressed on the other side.
Basically a “hello i want your attention here”
other side is like “yes i saw you”
and both buttons go red.
local blinking = false
local function Blink()
-- important early return, avoid creating multiple loops
if blinking then return end
blinking = true
while blinking do
loopingPart1.BrickColor = BrickColor.new("Smoky grey")
loopingPart2.BrickColor = BrickColor.new("Smoky grey")
task.wait(0.5)
-- changed order to (grey -> red) so it stays red if blinking is false
loopingPart1.BrickColor = BrickColor.new("Really red")
loopingPart2.BrickColor = BrickColor.new("Really red")
task.wait(0.5)
end
-- Or add an extra set color after to stay red if blinking is false
loopingPart1.BrickColor = BrickColor.new("Really red")
loopingPart2.BrickColor = BrickColor.new("Really red")
end
Flash.MouseClick:Connect(Blink)
local function stopBlink()
blinking = false
end
OtherButton.MouseClick:Connect(stopBlink)