JustPaste.it
while not ani_state.is_playing():
  yield(get_tree(), "idle_frame");
 
ani_state.travel(new_val);

 

while (ani_state.is_playing() and (ani_state.get_current_node() != new_val or ani_state.get_current_play_position()<ani_state.get_current_length())):
  yield(get_tree(), "idle_frame");

 

# Extra #
yield(get_tree(), "idle_frame");
yield(get_tree(), "idle_frame");
######

ani_state.stop();
sword_mode = ani_state.get_current_node();
property_list_changed_notify();