Need Help with Enemy Health

So my Problem is Currenty that i have a working healthsystem/health bar, but if i attack 1 enemy all the other ones get Damaged aswell.

this is my scripst so far:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HealthEnemy : MonoBehaviour
{

public int maxHealth = 100;
public int currentHealth;

public HealthBar healthBar;
// Start is called before the first frame update
void Start()
{
currentHealth = maxHealth;
healthBar.SetMaxHealth(maxHealth);

}

void OnTriggerEnter(Collider _collision){

if(_collision.gameObject.tag==“projectilefriendly”)
{
TakeDamage(20);
}

void TakeDamage(int damage)
{
currentHealth -= damage;

healthBar.SetHealth(currentHealth);
}
}
// Update is called once per frame
void Update()
{
if(currentHealth <= 0)
{
DestroyEntity();
}

void DestroyEntity()
{

Destroy(gameObject);
}

}
}

Are you instantiating your enemies into the game with another script?

The problem could be if you’re directly calling Instantiate(enemy,position,rotation) and not creating a separate instance for each enemy with GameObject enemyInstance = Instantiate(enemy,position,rotation) as directly calling it will basically link every copy of the object in the scene instead of having them be separate.

I’m not sure if that’s even relevant to your game, but your code looks fine so that’s what came to mind.

i already fixed it but thank u.

How did you fix it @MasouriSama ?