Missing Object aftrer Destroying it

Hello

I’m currently developing a game that has a spawner who lets opponents spawn.

The problem is: As soon as one of these opponents dies, they all die at the same time + the game object is removed from the spawner, so that nothing new is spawned.

Does anyone know why this could be?


Enemy Health Script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyHealth : MonoBehaviour
{

Rigidbody2D rb;
public static float healthAmountEnemy;


// Start is called before the first frame update
void Start()
{
    healthAmountEnemy = 1;
    rb = GetComponent<Rigidbody2D>();

}

// Update is called once per frame
void Update()
{

    if (healthAmountEnemy <= 0)
    {
       Destroy(gameObject);
       
    }
}
  void OnCollisionEnter2D(Collision2D other)
{
	if (other.gameObject.tag == "Bullet") 
	{
		healthAmountEnemy -= 0.4f;
	}
}

}


Enemy Spawner Script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemySpawner : MonoBehaviour
{

[SerializeField]
private float spawnRadius = 7;
private float time = 1.5f;
public GameObject[] enemies;

// Start is called before the first frame update
void Start()
{
    StartCoroutine(SpawnAnEnemy());
}

IEnumerator SpawnAnEnemy() 
{
    Vector2 spawnPos = GameObject.Find("Player").transform.position;
    spawnPos += Random.insideUnitCircle.normalized * spawnRadius;

    Instantiate(enemies[Random.Range(0, enemies.Length)], spawnPos, Quaternion.identity);

    yield return new WaitForSeconds(time);
    StartCoroutine(SpawnAnEnemy());

}

}

hi so im not professional to be clear
i think you should remove static of your healthAmountEnemy line this:
public float healthAmountEnemy = 100 ;
you can replace the health anytime you know so i think it solves the all enemy dying at same time
and about spawner
void update()
{
StartCoroutine(SpawnAnEnemy());
}
it’ll keep spawning in void update(basically every frame )
yea i think it might work