0
\$\begingroup\$

I'm using Game Maker Studio 2.

When I press the "Z" key I need audio to play, but I can't seem to get it to work.

I'm using the following code inside an object's Key Press event:

if keyboard_check_pressed("Z")
{    
   audio_play_sound(snd_menu_selection,1,false);
}
\$\endgroup\$
1
\$\begingroup\$

Maybe you have some misconception on the use of Game maker events.

Use the keyboard_check_ form when you are checking for key input in step event.

If you use the Key event there's no need for keyboard_check_ because it is already checking for the key to be pressed.

As you have your code, it will check "Z" key is pressed twice simultaneously (that's maybe impossible to perform XD), just keep the audio_play_sound line in the key event.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.