The AnimationPlayer is playing only the 1 frame

Godot Version

<3.5>

Question

extends KinematicBody2D

const UP = Vector2(0,-0.5)
const gravity = 5
const maxspeed = 100
const maxrunspeed = 200
const maxfallspeed = 300
const jumpforce = 190
const accel = 5
const run_accel = 10

var vilocity = Vector2()
var facing_right = true
var is_attackin = false

func _ready():
pass
func _physics_process(delta):
vilocity.y += gravity
if vilocity.y > maxfallspeed:
vilocity.y = maxfallspeed

if facing_right == true:
	$Sprite.scale.x = 1
else:
	$Sprite.scale.x = -1

vilocity.x = clamp(vilocity.x,-maxspeed,maxspeed)



if Input.is_action_pressed("right"):
	facing_right = true
	vilocity.x += accel
	$AnimationPlayer.play("run")
elif Input.is_action_pressed("left"):
	facing_right = false
	vilocity.x -= accel
	$AnimationPlayer.play("run")
else:
	if is_on_floor():
		vilocity.x = lerp(vilocity.x,0,0.25)
		$AnimationPlayer.play("idle")

vilocity = move_and_slide(vilocity,UP)

attack()
animation()

if is_on_floor():
	if Input.is_action_just_pressed("Jump"):
		vilocity.y = -jumpforce

if !is_on_floor():
	if vilocity.y < 0:
		$AnimationPlayer.play("jump")
	if vilocity.y > 0:
		$AnimationPlayer.play("fall")

func attack():
if Input.is_action_pressed(“attack”):
is_attackin = true
else:
is_attackin = false
func animation():
if is_attackin == true :
$AnimationPlayer.play(“attack”)

Better information is needed for this question. Maybe cropping the code snippet to only the necessary lines and describing what is happening and what you’re trying to achieve. But from what I can piece together from the title and the script is, there might be an issue with how animation logic is handled

I’m not a fan of how animation are handled here. I find it’s more convenient to update animation based on physics events, not input. Here’s a tip, you can place animation logic in a function, and call in a _process.

func _process(_delta):
	update_animation()

func update_animation():
	if is_on_floor():
		if velocity == Vector2.ZERO:
			$AnimationPlayer.play("idle")
		else:
			$AnimationPlayer.play("run")
	else:
		if velocity.y < 0:
			$AnimationPlayer.play("jump")
		
		if velocity.y > 0  && !is_on_floor():
			$AnimationPlayer.play("fall")

I basically reworked the animation logic as I’m still not sure what you’re asking for specifically. Make sure to define vilocity as velocity as it seem spelt wrong. I hope this helps