how do i make this animation work ?

GODOT 4.4
Replace this line with your Godot version

how do i make the animation of my dash work ? Anytime i try, it just doesn’t show up. I’m i doing anything wrong ( sorry if i did a stupid thing i’m really new to that kinda stuff ) thx in advance !

	if Input.is_action_just_pressed("dash") and dash_key_pressed == 0 and dash_number >= 1:
		dash_number -= 1
		dash_key_pressed = 1
		dash()
		
	if direction > 0:
		animated_sprite.flip_h = false
		
	elif direction < 0:
		animated_sprite.flip_h = true
		
	if is_on_floor():
		dash_number =1
		
		if direction == 0:	
			animated_sprite.play("Idle")
		else :	
			if Input.is_action_pressed("course"):
				animated_sprite.play("Run")
			else :
				animated_sprite.play("Walk")
		
		
			
	else:
		animated_sprite.play("Jump")
			
	if is_dashing == false:
		
		if direction:
			velocity.x = direction * walk_speed
		else:
			velocity.x = move_toward(velocity.x, 0, walk_speed)
		
	if Input.is_action_pressed("course"):
		walk_speed = sprint_speed
	else :
		walk_speed = 300
		

	
		

	move_and_slide()
	
func dash():
	if dash_key_pressed ==1:
		animated_sprite.play("Dash")
		is_dashing = true
		
			
	else :
		is_dashing = false
			
	if !animated_sprite.flip_h :
		velocity.x = dash_speed
		dash_started()
	if animated_sprite.flip_h :
		velocity.x = -dash_speed
		dash_started()

func dash_started():
	
	if is_dashing == true:
		animated_sprite.play("Dash")
		dash_key_pressed = 1
		await get_tree().create_timer(0.2).timeout
		is_dashing = false
		dash_key_pressed = 0	

Try adding print(animated_sprite.current_animation) after each play() and see what it prints when you dash.
Then, there is the AnimationTree node. It looks scary but it is the tool for switching animations, meaning it should be easier to set up, debug and add to than with scripts.

In this section of code you call dash(). But after returning from the dash() function your code hits this:

if is_on_floor():
		dash_number =1
		
		if direction == 0:	
			animated_sprite.play("Idle")
		else :	
			if Input.is_action_pressed("course"):
				animated_sprite.play("Run")
			else :
				animated_sprite.play("Walk")
else:
	animated_sprite.play("Jump")    

No matter what happens in the dash() function this block of code will switch the animation to either idle, run, walk, or jump.
If is_on_floor() is false you will play the jump animation.
If is_on_floor() is true you will play idle, run, or walk depending on the result of the other if statements.