Play sound once when button pressed

So im making a game and when the player dies he has to press the r button to restart
and when he does it plays a sfx but when i tried to do this and when i hold r it keeps looping.

So can you fix this? Here’s the events:

Try to use Released condition, Pressed condition will repeat per frame if the condition is true

i didn’t work for me

Try add “Trigger Once” in the condition field. Or add a sub-event then add Trigger Once at the condition filed.

Is the looping you mean is sound? then click loop to no in sound action

no i mean when i hold r it keeps repeating until i let go of r

it didn’t work the scene restarts before the sound can play

GD runs the code in sequence, so play the sound first, then change the scene.

You need to wait for the end of the sound to change scene, otherwise the sound won’t have any time to play.

can you show me a picture of the event?

I don’t use GD4, but there are probably conditions like “sound is playing”.

now it work’s thank you!

1 Like