Hello, so I was wondering how could I add additional time to a corountine that has already started?

So I’m making a FNAF Fan game, but I started it in 3D but that’s not the case.

I was making the door system and I have a corountine that counts a random time and when it reaches the end it will make a jumpscare. But when i close the door and stop the corountine, it wouldn’t restart and when I will start it again it will continue from where it was stopped. I tried counting the time when the door was open and closed but I can’t get it working. If anyone could respong it would mean a lot.

This is my code:

Update()
{
if (goToDoorLeft)
{
Coroutine Jumpsc = StartCoroutine(WaitBeforeJumpscare());
agent.SetDestination(doorPointLeft.transform.position);

        if (gm.door1.doorIsOpening == false)
        {
            StopCoroutine(Jumpsc);
            if (!hasCheckedT)
            {
                closedDoor = Time.time;
                closedDoor -= timeWhileOpen;
                closedDoor += randomTime;
                Debug.Log(randomTime);
                Debug.Log("Has closed at " + Time.time);
                hasCheckedT = true;
            }
        }
        else
        {

            if (!hasCheckedOpen)
            {
                timeWhileOpen = Time.time;

                Debug.Log(Time.time + "Has been opened");
                hasCheckedOpen = true;
            }

        }

IEnumerator WaitBeforeJumpscare()
{
    
    yield return new WaitForSeconds(randomTime);

    if (left)
    {
        Coroutine Jumpsc = StartCoroutine(WaitBeforeJumpscare());
        if (gm.door1.doorIsOpening)
        {
            gm.Jumpscare(gameObject.name);
            Debug.Log(gameObject.name);   
        }
        else
        {
            StartCoroutine(WaitBeforeLeavingLeft());
            
            StopCoroutine(Jumpsc);
        }
    }

}

I am slightly confused about your requirements and your code, but it might be easier to achieve what you want by using a timer (which is checked and modified in Update()) instead of coroutines, something like e.g.

public class Door : MonoBehaviour
{
    float timer;
    bool isOpen;

    public void Open()
    {
        timer = SomeRandomTime();
        isOpen = true;
    }

    public void Close()
    {
        isOpen = false;
    }

    void Update()
    {
        if (isOpen)
        {
            if (timer > 0)
            {
                timer -= Time.deltaTime;
            }
            else
            {
                Jumpscare();
                isOpen = false;
            }
        }
    }

    // ...
}