Ok, so the way I solved this problem was by using
Input.isactionjustpressed("uix")
to change the state of a variable "is_attacking".
This is placed within the main input "if" statement as an elif. I then have another elif check if "is_attacking" is true, and if it is, play the attack animation.
I then connect a signal for AnimationFinished from the AnimatedSprite to the Character's Script, and inside the function that's made, ensure that "isattacking" is made false.
So, back in my physicsprocess, "isattacking" will be true for one full animation cycle of the attack animation, and the animation stops after that.
Here's the code that I used. Declare a var is_attacking outside of the process :
func _physics_process(delta):
if Input.is_action_pressed("ui_right"):
#motion code
elif Input.is_action_pressed("ui_left"):
#motion code
elif Input.is_action_just_pressed("ui_x"):
attacking = true
elif attacking==true:
$char_sprites.play("Attack")
else:
motion.x=0
$char_sprites.play("Idle")
#Other stuff
func _on_char_sprites_animation_finished():
is_attacking=false
Hope this helps!