Attack animation keeps repeating and doesn't go back to idle animation, I am desperate

The animation of the attack just repeat when i click J (attack input).
Here’s my code:

extends CharacterBody2D
const SPEED = 300.0
const JUMP_FORCE = -490.0

var gravity = 1700
var is_jumping := false
var isAttacking = false

@onready var animation := $anim as AnimatedSprite2D

func _physics_process(delta):
if not is_on_floor():
velocity.y += gravity * delta

if Input.is_action_just_pressed("up") and is_on_floor():
	velocity.y = JUMP_FORCE
	is_jumping = true
elif is_on_floor():
	is_jumping = false

var direction = Input.get_axis("left", "right") 
if direction:
	velocity.x = direction * SPEED
	animation.scale.x = direction 
	if !is_jumping:"run")
elif is_jumping:"jump")
	velocity.x = move_toward(velocity.x, 0, SPEED)
	if !is_jumping and !isAttacking:"idle")
if Input.is_action_just_pressed("attack"):"attack")
	isAttacking = true

You set isAttacking to true but never reset it back to false so it won’t enter the block where you play the idle animation.

You’ll need to find a way to set isAttacking to false at some point.