How do I wait for an animated sprite to finish its animation

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

Basically, I am trying to get my character to when he stops moving, go into an idle state but only after a certain amount of seconds have passed.
This is my latest attempt.

extends AnimatedSprite

var idle: bool = false
var facing_right: bool = false
func _process(_delta: float) -> void:"walk")
	#checking user input
	if Input.is_action_pressed("right"):
		facing_right = true
	elif Input.is_action_pressed("left"):
		facing_right = false
	#flipping animations based on facing direction
	self.flip_h = facing_right
	#checking if player is stationary
	var velocity: Vector2 = get_parent().velocity
	if velocity.x > 0 or velocity.x < 0: #<- if they are moving"walk", false)
		if !idle:
			if $idle_timer.is_stopped():
#	print($idle_timer.time_left)

func _on_idle_timer_timeout() -> void:"idle", false)
	idle = true
:bust_in_silhouette: Reply From: Ertain

Have you looked at the animation_finished() signal of an AnimatedSprite? When the animation_finished() signal is emitted, play the “idle” animation. This should work (unless the AnimatedSprite is set to looping. In which case, it’ll get a bit trickier).