Take damage when Player collides with Enemy

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

public class playerHealth : MonoBehaviour {
    public int maxHealth = 100;
    public int currentHealth;
    public Text HP;
    public healthBar healthBar;
    void Start () {
        currentHealth = maxHealth;
        healthBar.SetMaxHealth(maxHealth);
    }
   

    void Update () {
        if (Input.GetKeyDown (KeyCode.H)) {
       
            TakeDamage (10);
        }

        HP.text = currentHealth.ToString ();
    }

    public void TakeDamage (int damage){
   
        currentHealth -= damage;
        healthBar.SetHealth (currentHealth);
    }

    void OnCollisionEnter(Collision col){
        if (col.gameObject.name == "Enemy") {
            TakeDamage (10);
       
        }
   
    }

}

I tried this but It didn’t work.

How unfortunate.

Now if only someone here could offer some more information such as:

  1. what do you expect it to do?
  2. what did it do?
  3. where do you think the problem might be?
  4. are there any errors on your console?
  5. etc.

It’s pretty much the basic steps to any problem solving process.

  1. It says in the title
  2. Nothing
  3. I don’t know
  4. No
  5. ?