move the action in 18 to line 7 that sets the global var
delete 16 and 19 entirely
and on line 17 add over the top of the 0 set animation to idle
this setup wont set the player to automatically resume walking animation though so change the line 5 condition to is moving
that should fix the entirety of it if you need more halp holla