End slowmotion effect after x seconds

Hello! I am currently working on my first 2d game and everytime when the player dies i want a slowmotion to appear for a few seconds. I didnt figure out how i can have a function for a certain amount of time. Can someone help me with the script? The trigger of the slowmo will be an if method

 public float slowdownfactor;
 public float slowdownlength;

 public gameobject player;

 public void start()
 {
    if (player.activeSelf = false)
    {
          Time.timeScale = slowdownfactor;
    }
 }

…and so on. Now i just need help so set the slowdown length. I hope someone can help me:)
~dvxl

Try using a Coroutie. Inside of the Coroutine you can use yield return new WaitForSecondsRealtime(slowdownlength);to wait without being affected by the slow motion.