Player animation is not working

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

i need a help my punch animation is not working when i press mouse click button

my code :

extends Node2D


@onready var animation = $AnimationPlayer

func _ready():
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	pass
	
func _input(event):
	if (event is InputEventMouseButton or event is InputEventScreenTouch) and event.is_pressed():
		animation.play("punch")
	
:bust_in_silhouette: Reply From: Tchebek

Make sure the node ‘$AnimationPlayer’ is correctly spell because the default name is ‘$AnimationPlayer2D’