EDIT: Wiped earlier posts, post was getting too long and untidy. Fixed your problem. You may need to modify the code a little for other animations, but this should give you the gist of it.
`Idle animation
IF KEYSTATE(17) = 0 `You can add AND and any other keystates corresponding with various animations
`If the sprite's current frame is out of range, set it to first frame within range
IF SPRITE FRAME(101) < 25: SET SPRITE FRAME 101, 25: ENDIF
PLAY SPRITE 101, 25, 48, 50
ENDIF
` rotates sprite left (A)
if keystate(30) then angle#=wrapvalue(angle#-4)
` rotates sprite right (D)
if keystate(32) then angle#=wrapvalue(angle#+4)
`Moves sprite forward (W)
IF KEYSTATE(17)
`If the sprite's current frame is out of range, set it to first frame within range
IF SPRITE FRAME(101) > 24: SET SPRITE FRAME 101, 1: ENDIF
PLAY SPRITE 101, 1, 24, 40
py# = py# - sin(angle#)*3
px# = px# - cos(angle#)*3
ENDIF
rotate sprite 101, (angle#)-90
You can see my edits as I code keywords in caps and use slightly different indents. You should apply this theory to all your animations.