My player detects collisions for one thing but doesn't for the other

Hi! So I was trying to make a platformer game. The player was detecting collisions with a patrolling enemy just fine and was respawning every time. However, when I tried the same method, but changed the trigger, it didn’t work. I may be making a very beginner-like mistake because I am one, but I hope someone will answer me.`using Cinemachine;
using UnityEngine;
using UnityEngine.SceneManagement;

public class PlayerDeath : MonoBehaviour
{
public DeathTrigger dt;
public float minYval;

private void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.CompareTag("Enemy"))
    {
        Destroy(gameObject);
        LevelManager.instance.Respawn();
    }

    if (collision.gameObject.CompareTag("DeathTrigger"))
    {
        Destroy(gameObject);
        LevelManager.instance.Respawn();
    }
}

}
`

Never mind, I fixed the collision by making a DeathTrigger script with an isDead boolean. Then I made an OnTriggerEnter2D function and set isDead to true. After that, in the PlayerDeath script, I got a deathTrigger reference and made an update function. In the update function I checked if isDead was true. If it was, I would respawn the player.