Why my attack animation won't play when I press the intended button?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Bacovel

So I have different animation for run, idle, jump and fall … and I have one for my attack animation. All the animations works how it supose to except for the attack. I am sorry I am new to coding :confused:

here is the player code: (just the _physics_process function)

func _physics_process(delta):
get_input()
velocity.y += gravity * delta
velocity = move_and_slide(velocity, Vector2.UP)

velocity.x = 0
if Input.is_action_pressed("right"):
	velocity.x += speed
	$AnimatedSprite.play("run")
	$AnimatedSprite.flip_h = false
	if sign($Position2D.position.x) == -1:
		$Position2D.position.x *= -1

elif Input.is_action_pressed("left"):
	velocity.x -= speed
	$AnimatedSprite.play("run")
	$AnimatedSprite.flip_h = true
	if sign($Position2D.position.x) == 1:
		$Position2D.position.x *= -1
else:
	if on_ground == true:
		$AnimatedSprite.play("idle")

if Input.is_action_just_pressed("space"):
	if is_on_floor():
		velocity.y = jump_speed
		

if Input.is_action_just_pressed("atac") && contor != 0:     # Here is the attack anim
	$AnimatedSprite.play("arunca")
	contor = contor-1
	
	var sticla = STICLA.instance()
	if sign($Position2D.position.x) == 1:
		sticla.set_sticla_direction(1)
	else:
		sticla.set_sticla_direction(-1)
	get_parent().add_child(sticla)
	sticla.position = $Position2D.global_position

if is_on_floor():
	on_ground = true
else: 
	on_ground = false
	if velocity.y >0:
		$AnimatedSprite.play("fall")
	else:
		$AnimatedSprite.play("jump")
:bust_in_silhouette: Reply From: Sansduke

If the input is “atac” then it is NOT “right” or “left” so

else:
if on_ground == true:
    $AnimatedSprite.play("idle")

will be ran