My player is stuck in his attack animation when I pressed it once, do I miss something in my code?

Every movement animation works but for the attack animation not here’s my code

extends CharacterBody2D
class_name player

@export var speed : int = 150
@export var jump_force : int = 255
@export var gravity : int = 900

var is_attacking = false

#Player Movement
func _physics_process(delta):
var direction = Input.get_axis(“left”,“right”)

if direction:
	velocity.x = direction * speed
	if is_on_floor() and is_attacking == false:
		$AnimatedSprite2D.play("walk")
else:
	velocity.x = 0
	if is_on_floor() and is_attacking == false:
		$AnimatedSprite2D.play("idle")

#Animation left and right
if direction == 1:
$AnimatedSprite2D.flip_h = false
elif direction == -1:
$AnimatedSprite2D.flip_h = true

#Jump
if Input.is_action_pressed(“jump”) and is_on_floor():
velocity.y -= jump_force
$AnimatedSprite2D.play(“jump”)

#Gravity
if not is_on_floor():
velocity.y += gravity * delta

#Claw attack animation
if Input.is_action_pressed(“attack”):
$AnimatedSprite2D.play(“attack”)
is_attacking = true
await $AnimatedSprite2D.animation_finished
is_attacking = false

move_and_slide()

There’s a few similar functions. one is ‘is_action_just_pressed’, which return true once and stop, but the one you are using will echo the key stroke and return true multiple times.