Make sure to paste scripts instead of screen shots
Seems like you must be getting an error no? Does your game freeze and the editor present a stack trace?
I believe your anim variable needs a dollar sign, this means to get a node named “AnimatedSprite2D”, without the dollar sign it gets a different value that isn’t useful.