Connect the signal "on_animation_finsihed(anim_name)" to func _on_animation_finsihed(anim_name)
as in:
func _on_animation_finsihed(anim_name):
if anim_name == "ATTACK": get_node("AnimationPlayer").play("IDLE")
NOTE: This assumes that your "attack" animation is called "ATTACK", and your idle animation is called "IDLE".