2 Pathfinding enemies not working at the same scene

I made an enemy with a pathfinding AI. However, if I put a copy of the enemy on the same scene, the project will crash
How can I make it so 2 or more copies of the pathfiniding enemy will work on the same scene?

My code
extends CharacterBody2D

const speed = 25

@export var player: Node2D
@onready var nav_agent := $NavigationAgent2D as NavigationAgent2D

func _physics_process(_delta: float) → void:
var dir = to_local(nav_agent.get_next_path_position()).normalized()
velocity = dir * speed
move_and_slide()

func makepath() → void:
nav_agent.target_position player.global_position

func _on_timer_timeout():
makepath()

func enemy():
pass

func _on_collision_body_entered(body):
if body.get_name() == “bolinha”:
queue_free()

func _on_detection_area_body_entered(body):
if body.get_name() == “player”:
get_tree().change_scene_to_file(“res://Scene/world.tscn”)

So with just one enemy it works? Did you add another instance, or did you use copy and paste on the existing node? If the latter: Does your enemy scene use any resources that might be shared between the two nodes and lead to an error? (You can right-click on any resource and choose “Make Unique” to prevent that from happening). If you say “crash”, do you mean the engine or your game? Are there any errors?