Player lose health ontriggerenter2d with coroutine

I want to make player lose health when player hit a certain object. The object appear and disappear with coroutine. It didn’t work somehow. Any solution?

public class Coroutine : MonoBehaviour
{
public GameObject laser;
public int laserOnOff;

void Start()
{
    StartCoroutine(LaserFlickering());
}

void OnTriggerEnter2D(Collider2D col)
{
    if (col.gameObject.tag == "Player")
    {
        HealthControl.health -= 1;
    }
}

IEnumerator LaserFlickering()
{
    while (laserOnOff < 100)
    {
        yield return new WaitForSeconds(2);
        laser.SetActive(false);
        yield return new WaitForSeconds(2);
        laser.SetActive(true);
        laserOnOff += 1;
    }
}

}

Actually your code is looking good .Could you try add debug line in On trigger enter function “line 7” if it works there is a problem about your tag proably your player have a wrong tag else if proably problem is rigidbody 2d .Could you check are player and laser gameobject have a rigidbody 2d component if they have then problem is about components .Could you check are both gameobject have a rigidbody 2d and collision 2d .I hope these will solve your problem =)