Here's what I tried before waiting for a savior:
I tried adding a ready function such as:
$AnimatedSprite2D._on_animated_sprite_2d_animation_finished.connect("animation_finished")```
Then I changed up the handle_attack function as such:
```func handle_attack():
# Calculate the direction based on mouse position
var mouse_position = get_global_mouse_position()
var player_direction = (mouse_position - global_position).normalized()
# Load the arrow scene
var arrow_scene = preload("res://Instanced_Objects/arrow.tscn")
assert(arrow_scene, "Error loading arrow scene")
# Instance the arrow scene
var arrow_instance = arrow_scene.instantiate() as Node # Use the appropriate type
# Set the arrow's position
arrow_instance.global_position = global_position
# Set arrow properties (direction, speed, damage, etc.)
arrow_instance.direction = player_direction
arrow_instance.damage = bow_damage
arrow_instance.speed = arrow_speed
# Add the arrow to the scene
get_tree().current_scene.add_child(arrow_instance)
arrow_instance.look_at(get_global_mouse_position())
# Determine the attack animation based on the mouse position
var attack_animation_suffix = get_animation_suffix(player_direction)
# Play the appropriate attack animation
$AnimatedSprite2D.play("attack_" + attack_animation_suffix)
if $AnimatedSprite2D.animation_finished("attack_"):
attacking = false
func _on_animated_sprite_2d_animation_finished():
pass # Replace with function body.
Tried that, now it crashes immediately saying:
"Invalid getindex '_on_animated_sprite_2d_animation_finished' (on base: 'AnimatedSprite2D')"