Script sometimes working and sometimes not.

I have a script called Attack.cs, it works on both enemies on my prototype, but on “Level01” it is only working on one Enemy, the other one could just as well not be there. When working it is doing what i wants it to.

`using UnityEngine;
using System.Collections;

public class Attack : MonoBehaviour {
	public GameObject player;

	
	void OnTriggerEnter (Collider other) {
		if (other.gameObject.tag == "Player"){
			player.GetComponent<PlayerScript>().death();

		}
	}



	
}`

This is the script it is calling

 using UnityEngine;
    using System.Collections;
    
    public class PlayerScript : MonoBehaviour {
    	
    
    	public bool dead = false;
    	public GameObject player;
    
    	public static bool enable;
    
    
    	public void death()
    	{  if (enable)
    		dead = true;
    	}
    	void Update () 
    	{
    		if(dead)
    		{
    			player.GetComponent<FPSWalkerEnhanced>().enabled = false;
    			player.GetComponent<LookMouse>().enabled = false;
    			player.GetComponentInChildren<LookMouseY>().enabled = false;
    			StartCoroutine(deads());
    
    		}
    		
    
    	}
    	IEnumerator deads()
    	{
    		yield return new WaitForSeconds(3);
    		Application.LoadLevel(Application.loadedLevel);
    	}
    }

Can anyone tell me why it is selective in when it is working? Prefabs are the same in both scenes.

Perhaps you could use something with OnTriggerStay. I have enemies that spawn so close that it isn’t even entered, but it is staying.
Then you could use booleans to make sure OnTriggerStay only gets called once.

 void OnTriggerEnter (Collider other) {
             if ((other.gameObject.tag == "Player")&&(booler)){
                 player.GetComponent<PlayerScript>().death();
    booler = false;
     
             }
         }

Note: Let’s say you DON’t want to only be called once, then maybe you could do something like this

         void OnTriggerEnter (Collider other) {
             if ((other.gameObject.tag == "Player")&&(booler)){
                 InvokeRepeating("hurt", 0, 1);
     booler = false;
             }
         }

IEnumerator hurt(){
                 player.GetComponent<PlayerScript>().death();}