Game Maker Studio 2 Drag And Drop Tutorial

It’s actually far easier than you would think.

First, remove the even Keyboard – no key. It’s not needed.

I made two different sets of sprites – one with the animation for idle and another with the animation for walking; for each direction.

I have the FPS set to 60, so adjust your values to your liking

In the Player Object Create event I used the following objects:

Assign Variable object – name: animate (or similar) and set the value to 0
Assign Variable object – name: player speed (or similar) and set the value to 1.5 (or how ever fast you want your character to move)

In the events to the player object, I set the Key Down events for UP, LEFT, DOWN, and RIGHT.
In each of them, I used the following objects:

If Variable object. I used it to check the animate variable is equal to 0, if true, then

Set Sprite object – Assign the animation object to the direction for the key pressed for the non-idle animation
Assign Variable object – Assign the animate variable to 1, which will be used to skip this section in the next run (otherwise, you will never get away from the first frame in the animation sequence)​

Jump To Point object – This is connected to the Left side of the IF Variable object

If the LEFT direction, X = -playerspeed, Y = 0; both Relative checkboxes are checked
If the RIGHT direction, X = playerspeed, Y = 0; both Relative checkboxes are checked
If the UP direction, X = 0, Y = -playerspeed; both Relative checkboxes are checked
If the DOWN direction, X = 0, Y = playerspeed; both Relative checkboxes are checked

Additionally, I set the Key Up events for UP, LEFT, DOWN, and RIGHT.
In each of them, I used the following objects:

Set Sprite object – Assign it to the animation object to the direction to start the idle animation
Assign Variable object – Assign the animate variable to 0

The idea is to keep the animation moving while the button is pressed for any direction, but then will switch back to the idle animation after the key(s) are released in any given direction.
Hope this helps!

Source: https://forum.yoyogames.com/index.php?threads/drag-and-drop-basic-movement-collision-walking-animation-tutorial-part-1-2-3-4-gms2.27672/