How can I attack while i'm walking (the animation of attacking are stopping me)

extends CharacterBody2D

var input
@export var speed = 110.0
@export var gravity = 0.4
@export var jump_force = 350
@export var max_jump = 2
var jump_count = 0

var current_state = player_states.MOVE
enum player_states {MOVE,SWORD}

Called when the node enters the scene tree for the first time.

func _ready():
$sword/sword_colider.disabled = true

Called every frame. ‘delta’ is the elapsed time since the previous frame.

func _process(delta):
match current_state:
player_states.MOVE:
movement(delta)
player_states.SWORD:
sword(delta)

CODE MOUVEMENT

func movement(delta):

input = Input.get_action_strength("ui_right")-Input.get_action_strength("ui_left")

if input != 0:
	$anim.play("Walk")
	if input > 0:
		velocity.x += speed * delta
		velocity.x = clamp(speed, 100 , speed) 
		$Sprite.scale.x = 1
		$sword.position.x = 15
		
	if input < 0:
		velocity.x -= speed * delta 
		velocity.x = clamp(-speed, 100 , -speed) 
		$Sprite.scale.x = -1
		$sword.position.x = -15
		
		
if input == 0 :
	velocity.x = 0
	$anim.play("Idle")
	

	#CODE FOR JUMPING
if is_on_floor():
	jump_count=0
	
if !is_on_floor():
	if velocity.y>0:
		$anim.play("fall")
	if velocity.y<0:
		$anim.play("jump")
	
if Input.is_action_pressed("ui_accept") && is_on_floor() &&  jump_count < max_jump:
	jump_count += 1
	velocity.y -= jump_force 
	velocity.x = input 


if !is_on_floor() && Input.is_action_just_pressed("ui_accept") &&  jump_count < max_jump :
	jump_count += 1
	velocity.y -= jump_force * 1.2
	velocity.x = input 
	
	
if !is_on_floor() && Input.is_action_just_released ("ui_accept") &&  jump_count < max_jump :
	velocity.y = gravity
	velocity.x =  input

	
	
	

	


	
gravity_force ()
move_and_slide()
if Input.is_action_just_pressed("ui_sword"):
	current_state=player_states.SWORD

func sword(delta):
$anim.play(“Sword”)
sword_walking(delta)

func sword_walking(delta):
input = Input.get_action_strength(“ui_right”)-Input.get_action_strength(“ui_left”)
if input != 0:
if input > 0:
velocity.x += speed * delta
velocity.x = clamp(speed, 100 , speed)
if input < 0:
velocity.x -= speed * delta
velocity.x = clamp(-speed, 100 , -speed)
if input == 0 :
velocity.x = 0

func reset_state():
current_state=player_states.MOVE

func gravity_force ():
velocity.y += gravity