Problems with prefabs

Hello guys , i have a problem with my prefabs
ok i made an enemy object , put a circle collider2D and then added a script to it (which is a health manager for the enemy)
i then made a sword put a box collider2D on it and added a script to it (hurt enemy)
i tested the game it worked perfectly the enemy was loosing health and it the enemy was deactivated
then i took the enemy and made a prefab of it by dragging it from the explorer to the project folder
then i dragged the prefab twice into the explorer and now i have 3 enemies in the scene.
Now when the swords touches enemy1 for example , enemy0’s health is affected and enemy1 health is still the same , when the swords touches enemy2 , enemy’s0 health is affected and enemy2 health is the same.
PLease help
here are the codes:

enemy health manager:(hooked on the enemies)

using UnityEngine;
using System.Collections;

public class EnemyHealthManager : MonoBehaviour {

public int maxhealth;
public int currenthealth;

// Use this for initialization;
void Start () {

	currenthealth = maxhealth;
}

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

	if (currenthealth <= 0)
		gameObject.SetActive (false);

}

public void hurtenemy(int damage)
{
	currenthealth -= damage;
	
}

public void healenemy(int healamount)
{
	currenthealth += healamount;
}

}

hurt enemy: (hooked on sword)

using UnityEngine;
using System.Collections;

public class HurtEnemy : MonoBehaviour {

private EnemyHealthManager theenemyhealthmanager;
public int damage;

// Use this for initialization
void Start () {

	theenemyhealthmanager = FindObjectOfType<EnemyHealthManager> ();
}

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

}

void OnCollisionEnter2D (Collision2D other)
{
	if(other.gameObject.tag == "enemy")
	{
		theenemyhealthmanager.hurtenemy (damage);
	}

}

thank you in advance

}

Right now, you’re defining a single instance of the EnemyHealthManager script in your start function. Not only will this exclude all health-diminishing functions to one instance, It also won’t work if the player’s not spawned the moment that function is called.

What you want to do is to get the script instance of the object currently being attacked. To do this, use the parameter sent from the OnCollitionEnter2D function (in this case, Collision2D other):

		EnemyHealthManager healthManagerInstance = other.collider.GetComponent<EnemyHealthManager> ();
		//Use the newly created variable in place of theenemyhealthmanager

This code snipped (which goes inside your if statement inside the OnCollisionEnter2D function) takes the collision, gets it’s collider (the enemy/object you hit) and then gets an EnemyHealthManager script attached to it. I suggest you also add an if statement to verify it GetComponent returns null to avoid NullReferenceException errors.

Good luck! Let me know if you need follow-up help