How do I add respawn time or respawn delay?

I am completely new to using unity and this is my first project (a 2d platformer). I keep following tutorials on youtube but I still don’t know what’s wrong with my script. I am trying to add a respawn time which waits for an amount of time before respawning after you die but all that happens is that the player dies. I can make it that the player respawns instantly but I don’t like it that way. this the script that im using:

Player death script:

public class PlayerDeath : MonoBehaviour
{
    public GameObject DeathEffect;
    public Transform Player;

    public void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Danger"))
        {
            StartCoroutine("Rspawn");
            GameObject Effect = Instantiate(DeathEffect, Player.position, Quaternion.identity);
            Destroy(gameObject);
            Destroy(Effect, 2f);
        }
    }

    IEnumerator Rspawn()
    {
        yield return new WaitForSeconds(2);
        Debug.Log("Respawning");
        LevelManager.instance.Respawn();
        Debug.Log("Respawned");
        StopCoroutine("Rspawn");
    }
}

and if you need it here is my level manager script:

public class LevelManager : MonoBehaviour
{
    public static LevelManager instance;

    public Transform RespawnPoint;
    public GameObject PlayerPrefab;

    public CinemachineVirtualCameraBase cam;

    private void Awake()
    {
        instance = this;
    }

    public void Respawn()
    {
        GameObject Player = Instantiate(PlayerPrefab, RespawnPoint.position, Quaternion.identity);
        cam.Follow = Player.transform;
    }
}

There aren’t any errors showing up in console so I don’t know what the problem is.

Well your scripts are pretty decent currently and what you expect should works. What’s going wrong ?

Edit: the issue is that you are destroying the local player gameobject and all his stuff before the respawn function getting called. (line 13 run before line 21)

So basically what you need to do is :

 if (collision.gameObject.CompareTag("Danger"))
 {
     StartCoroutine("Rspawn");
     GameObject Effect = Instantiate(DeathEffect, Player.position, Quaternion.identity);

     //Destroy(gameObject); You't must not destroy it now otherwise coroutines will not runs entirely. What you need is to disable the render of your player, also disable his scripts except this one. Destroy the game object in the coroutine after the respawn.

     Destroy(Effect, 2f);
 }

I assume your components are attached to game objects in the scene? Common mistake. If not, create an empty game object and attach the LevelManager to it. Attach PlayerDeath to the player prefab.