Lose health on collision

[EDIT]: Yes, the “Is Trigger” is checked.

When the player collides with an enemy, he doesn’t lose health. But when he attacks the enemy, enemy loses. And they have almost the same scripts.

Enemy.cs

using UnityEngine;
using System.Collections;

public class Enemy : MonoBehaviour {
	public int currentHealth = 2;
	public int maxHealth = 2;
	
	void Start () {
		
	}
	
	void Update () {
		if(currentHealth > maxHealth) {
			currentHealth = maxHealth;
		}
		
		if(currentHealth <= 0) {
			currentHealth = 0;
			Die();
		}
	}
	
	void Die() {
		Destroy(gameObject);
	}
	
	void OnTriggerEnter(Collider col) {
		if (col.tag == "Player") {
			ScoreAndHealthSystem sh = (Player)ScoreAndHealthSystem.GetComponent("ScoreAndHealthSystem");
			sh.currentHealth--;
		}
	}
}

The problem is probably at “void OnTriggerEnter”


ScoreAndHealthSystem.cs

using UnityEngine;
using System.Collections;

public class ScoreAndHealthSystem: MonoBehaviour {
	public int currentScore = 0;
	public int maxScore = 100;
	public int currentHealth = 3;
	public int maxHealth = 99;
	public int damage = 1;

	void Start () {
	
	}
	
	void Update () {
		if(currentScore > maxScore) {
			currentScore = maxScore;
		}
		
		if(currentScore < 0 ) {
			currentScore = 0;
		}
		
		if(currentScore == maxScore) {
			GiveExtraLife();
		}
		
		if(currentHealth < 0) {
			currentHealth = 0;
			GameOver();
		}
		
		if(currentHealth > maxHealth) {
			currentHealth = maxHealth;
		}
	}
	
	void GiveExtraLife() {
		currentHealth++;
		currentScore = 0;
	}
	
	void OnTriggerEnter(Collider col) {
		if (col.tag == "Collectible") {
            currentScore++;
			Destroy(col.gameObject);
         }
	}
	
	void GameOver() {
		
	}
}

PlayerAttack.cs

using UnityEngine;
using System.Collections;

public class PlayerAttack : MonoBehaviour {
	public GameObject enemy;

	void Start () {
		
	}
	
	void Update () {
		if(Input.GetMouseButtonUp(0)) {
			Attack();
		}
	}
	
	void Attack() {
		float dis = Vector3.Distance(enemy.transform.position, transform.position);
		
		Debug.Log(dis);
		
		if(dis <= 1.3) {
			Enemy eh = (Enemy)enemy.GetComponent("Enemy");
			eh.currentHealth--;
		}
	}
}

Solved. I’m the stupidiest person ever. I realized, why I got that error. It’s because I did it like this:

OnTriggerEnter(Collider col) {
   if(col.tag == "Example") {
      DoSomething()
   }
}

OnTriggerEnter(Collider coll) {
   if(coll.tag == "Example_two") {
      DoSomething()
   }
}

Instead of this:


OnTriggerEnter(Collider col) {
   if(col.tag == "Example") {
      DoSomething()
   }
   
   if(col.tag == "Example_two") {
      DoSomething()
   }
}