Fnaf Rebot, not working with, Door.

I am making a FNAF game and, I have code for doors, but when I run it, I always die, or I always don’t die. Can someone please help me the code for the doors, and the code for the animatronic is below!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Doors : MonoBehaviour
{
    //Code For The Doors. 

    public GameObject DoorLeft;
    public GameObject DoorRight;

    public bool DoorLeftActive = false;
    public bool DoorRightActive = false;

    // Start is called before the first frame update
    void Start()
    {
        DoorLeft.SetActive(false);
        DoorRight.SetActive(false);
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            if (DoorLeftActive)
            {
                DoorLeft.SetActive(false);
                DoorLeftActive = false;
                Movement.IsOnStageOfDeath = false;
                Debug.Log("Stage of Death is = 0");
            } else 
            {
                DoorLeft.SetActive(true);
                DoorLeftActive = true;
                Movement.IsOnStageOfDeath = true;
                Debug.Log("Stage of Death is = 1");
            }

        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            if (DoorRightActive)
            {
                DoorRight.SetActive(false);
                DoorRightActive = false;
                Movement.IsOnStageOfDeath = false;
            }
            else
            {
                DoorRight.SetActive(true);
                DoorRightActive = true;
                Movement.IsOnStageOfDeath = true;
            }

        }
    }
}


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Movement : MonoBehaviour
{
    //Code for the Animatronic.

    public GameObject Bonnie;

    public GameObject SpawnPoint;
    /// //////////////////////////////////
    public GameObject BonnieFirstOutput;
    public GameObject BonnieSecondOutput;
    public GameObject BonnieThirdOutput;
    /// ///////////////////////////////////////
    public GameObject BonniesFirstPositionOutput;
    public GameObject BonnieSecondPositionOutput;
    /// ////////////////////////////////////////
    public GameObject BonniesSecondToLast01;
    public GameObject BonniesSecondToLast02;

    float RandomNumberToStart;
    public static bool IsOnStageOfDeath = false;


    // Start is called before the first frame update
    void Start()
    {
        StartCoroutine(StartFirstPosition());
    }

    IEnumerator StartFirstPosition()
    {
        Debug.Log("StartingWaitTime");

        int RandomJumpscareStart = Random.Range(30, 100);
        yield return new WaitForSeconds(RandomJumpscareStart);

        int WhichPoint = Random.Range(1, 4);

        if (WhichPoint == 1)
        {
            Debug.Log("First Point");
            Bonnie.transform.position = BonnieFirstOutput.transform.position;
           
        }
        if (WhichPoint == 2)
        {
            Debug.Log("SecondPoint");
            Bonnie.transform.position = BonnieSecondOutput.transform.position;
     
        }
        if (WhichPoint == 3)
        {
            Debug.Log("Third Point");
            Bonnie.transform.position = BonnieThirdOutput.transform.position;

        }

        StartCoroutine(StartSecondPosition());

    }

    IEnumerator StartSecondPosition()
    {
        Debug.Log("StartingSecondWaitTime");

        int RandomJumpscareStart = Random.Range(45, 95);
        yield return new WaitForSeconds(RandomJumpscareStart);

        int WhichPoint = Random.Range(1, 3);

        if (WhichPoint == 1)
        {
            Debug.Log("First Point");
            Bonnie.transform.position = BonniesFirstPositionOutput.transform.position;
           
        }
        if (WhichPoint == 2)
        {
            Debug.Log("SecondPoint");
            Bonnie.transform.position = BonnieSecondPositionOutput.transform.position;
        }

        StartCoroutine(StartThirdPosition());
    }

    IEnumerator StartThirdPosition()
    {
        Debug.Log("StartingSecondWaitTime");

        int RandomJumpscareStart = Random.Range(20, 50);
        yield return new WaitForSeconds(RandomJumpscareStart);

        int WhichPoint = Random.Range(1, 3);

        if (WhichPoint == 1)
        {
            Debug.Log("First Point");
            Bonnie.transform.position = BonniesSecondToLast01.transform.position;

        }
        if (WhichPoint == 2)
        {
            Debug.Log("SecondPoint");
            Bonnie.transform.position = BonniesSecondToLast02.transform.position;
        }
        IsOnStageOfDeath = true;

        StartCoroutine(VergeOfDeath());
    }

    IEnumerator VergeOfDeath ()
    {
        yield return new WaitForSeconds(8);

        if (IsOnStageOfDeath = false)
        {
            Bonnie.transform.position = SpawnPoint.transform.position;
            StartCoroutine(StartFirstPosition());
        } else if (IsOnStageOfDeath = true)
        {
            JumpScare();
        }
    }

    void JumpScare()
    {
        Debug.Log("You Got Stuffed");
        PlayerPrefs.SetString("lastLoadedScene", SceneManager.GetActiveScene().name);
        SceneManager.LoadScene("Fail Scene");
    }
}

Simplify your Door script to just

using UnityEngine;

public class Doors : MonoBehaviour
{

public GameObject DoorLeft;
public GameObject DoorRight;

void Start()
{
    DoorLeft.SetActive(false);
    DoorRight.SetActive(false);
}

void Update()
{
    //All we're doing is toggling the doors. If they're active, we deactivate them; if they're inactive, we activate them
    
    if (Input.GetKeyDown(KeyCode.A))
    {
        DoorLeft.SetActive(!DoorLeft.activeSelf);
    }
    else if (Input.GetKeyDown(KeyCode.D))
    {
        DoorRight.SetActive(!DoorRight.activeSelf);
    }
    //If either of the doors are active,  Movement.IsOnStageOfDeath is true, otherwise it's false.
    Movement.IsOnStageOfDeath = (DoorLeft.activeSelf || DoorRight.activeSelf);
}
}

An then in your Movement function, re-write your VergeOfDeath coroutine to

IEnumerator VergeOfDeath()
{
    yield return new WaitForSeconds(8);

    if (IsOnStageOfDeath == false)
    {
        Bonnie.transform.position = SpawnPoint.transform.position;
        StartCoroutine(StartFirstPosition());
    }
    else
    {
        JumpScare();
    }
}

Could u tell me how to implement that verge of death , like how to make it work what i have to do