title: Script not working with multiple same objects
body: <p>I am developing a 2D game. There are different enemies in the game, but I am being stuck with one of them. The enemy is a monster with a hammer in the hand. When the player enters in it's range, it runs towards the player and attacks him with the hammer. Everything worked fine. I made a prefab of it and used it in the rest of my game. But then I noticed that enemy is attacking and even the script is working as I can see the hammer collider at the time of enemy attack. But that collider was not damaging the player. I checked everything from script to tags and colliders, but nothing worked. Then I created a separate scene to sort out the issue. I just dragged my player and the enemy from prefab folder to the scene and guess what it was working there. Which mean that if there was only one enemy (one instance of it), everything worked but not when I created the second instance of the same enemy with the same scripts and everything else. Just can't sort out the issue. <a href="https://i.stack.imgur.com/8dZRR.png" rel="nofollow noreferrer">Hammer Enemy</a>  </p>
  
  <p>Monster script:</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class Monster : MonoBehaviour {
  
      private static Monster instance;
  
      public static Monster Instance
      {
          get {
              if (instance == null) {
                  instance = GameObject.FindObjectOfType&lt;Monster&gt; ();
              }
              return instance;
          }
      }
  
      //Movement Variables
      public float movementSpeed;
      private IMonsterState currentState;
      public Animator MyAnimator{ get; set;}
      public GameObject Target{ get; set;}
      bool facingRight;
      public bool Attack{ get; set;}
      public bool TakingDamage{ get; set;}
      public float meleeRange;
  
      public Transform leftEdge;
      public Transform rightEdge;
  
      public float pushBackForce;
  
      public EdgeCollider2D attackCollider{ get; set;}
  
      //public EdgeCollider2D monsterhammer;
  
  
      public bool InMeleeRange
      {
          get{
              if (Target != null) {
                  return Vector2.Distance (transform.position, Target.transform.position) &lt;= meleeRange;
              }
              return false;
          }
      }
  
      // Use this for initialization
      void Start () {
  
          ChangeState(new IdleState());
          MyAnimator = GetComponent&lt;Animator&gt; ();
          attackCollider = GetComponentInChildren&lt;EdgeCollider2D&gt; ();
          //attackCollider=monsterhammer;
          facingRight = true;
      }
  
      // Update is called once per frame
      void FixedUpdate () {
  
          if (!Attack) {
              attackCollider.enabled = false;
          }
  
          if (!TakingDamage) {
              currentState.Execute ();
          }
          LookAtTarget ();
      }
  
      private void LookAtTarget()
      {
          if (Target != null) {
              float xDir = Target.transform.position.x - transform.position.x;
  
              if (xDir &lt; 0 &amp;&amp; facingRight || xDir &gt; 0 &amp;&amp; !facingRight) {
                  ChangeDirection ();
              }
          }
      }
  
      public void ChangeState(IMonsterState newState)
      {
          if (currentState != null) {
              currentState.Exit ();
          }
  
          currentState = newState;
          currentState.Enter (this);
      }
  
      public void Move()
      {
          if (!Attack) {
              if ((GetDirection ().x &gt; 0 &amp;&amp; transform.position.x &lt; rightEdge.position.x) || (GetDirection ().x &lt; 0 &amp;&amp; transform.position.x &gt; leftEdge.position.x)) {
                  MyAnimator.SetFloat ("speed", 1);
                  transform.Translate (GetDirection () * (movementSpeed * Time.deltaTime));
              } 
              else if (currentState is MonsterPatrol) 
              {
                  ChangeDirection ();
              }
          }
      }
  
      public Vector2 GetDirection()
      {
          return facingRight ? Vector2.right : Vector2.left;
      }
  
      public void ChangeDirection()
      {
          facingRight = !facingRight;
          Vector3 theScale = transform.localScale;
          theScale.x *= -1;
          transform.localScale = theScale;
      }
  
      public void MoveLeft()
      {
          facingRight = false;
          Vector3 theScale = transform.localScale;
          theScale.x *= -1;
          transform.localScale = theScale;
      }
  
      public void MoveRight()
      {
          facingRight = true;
          Vector3 theScale = transform.localScale;
          theScale.x *= -1;
          transform.localScale = theScale;
      }
  
      void OnTriggerEnter2D(Collider2D other)
      {
          currentState.OnTriggerEnter (other);
      }
  
      void OnCollisionStay2D(Collision2D other)
      {
          if (other.gameObject.tag == "Player") {
  
              playerHealth thePlayerHealth = other.gameObject.GetComponent&lt;playerHealth&gt; ();
              thePlayerHealth.addDamage (2);
  
              //if (playerHealth.damaged) {
              pushBack (other.transform);
              //}
          }
      }
  
      void pushBack(Transform pushedObject)
      {
          //Vector2 pushDirection = new Vector2 (0, (pushedObject.position.y - transform.position.y)).normalized;
          //pushDirection *= pushBackForce;
          Rigidbody2D pushRB = pushedObject.gameObject.GetComponent&lt;Rigidbody2D&gt; ();
          pushRB.velocity = Vector2.zero;
  
          if (pushedObject.position.x &gt; transform.position.x) {
              pushRB.AddRelativeForce (Vector3.right * pushBackForce);
          } else {
              pushRB.AddRelativeForce (Vector3.left * pushBackForce);
          }
      }
  
      public void MeleeAttack()
      {
          attackCollider.enabled = true;
      }
  }
  </code></pre>