Temp tone

Hello, I am new to arduino, and coding.

I am developing a sort of laser tag. And I have a speaker that plays a sound effect when a button is pressed. But, as of right now, the speaker continues to play while the button is pressed. This is all happening in the void loop. Is there a way that I can get the speaker to stop playing until the button is pressed again?

I want the speaker to play for 250 milliseconds after the button is initially pressed, then stop. Then once the bed is pressed again repeat. This is so if someone holds the button, the speaker does not continue to play.

Any ideas would be greatly appreciated.

Is there a way that I can get the speaker to stop playing until the button is pressed again?

Sure there is, but without knowing what you have done it is impossible to know what you have done wrong.

Please post your code and use the copy for forum option in the IDE before pasting in into your reply.

The StateChangeDetection example is relevant here, checkout how this is done.