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")

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.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .