Open a door once 3 Triggers have been pressed

I’m new to unity and I’m trying to make a door that opens only once 3 separate buttons (GameObjects) have been pushed. I tried to use CompareTag to assign tags to the player once they push a button. Once a second button is pushed, the first tag (“1Button”) is swapped for the second tag (“2Button”). The same for the 3rd button. Once all 3 buttons are pushed, the player should have the 3rd button tag on them, which would open the door.

{
    [SerializeField]

    public GameObject DepressedButton;
    public GameObject door;
    public GameObject player;

    
    //bool isOpened = false;
    //public var IsPressed : boolean = false;

    void Start()
    {
        gameObject.SetActive(true);

        DepressedButton.SetActive(false);


        //starts player with no button tag
        player.tag = "NoButton";
    }
    void OnTriggerEnter(Collider other)
    {

        if (player.gameObject.CompareTag("NoButton") )
        {
            player.tag = "1Button";
        }
        if (player.gameObject.CompareTag("1Button")) 
        {
            player.tag = "2Button";
        }
        if (player.gameObject.CompareTag("2Button"))
        {
            player.tag = "3Button";
        }
        Debug.Log("button was pressed");
        //turn off regular button
        gameObject.SetActive(false);   

        //turn on depressed button
        DepressedButton.SetActive(true);

    }

    void Update()
    {
       
        {
            if(player.gameObject.CompareTag("3Button"))
            {
                Destroy(door);
            }
        }
    }

}

Create a script “Door” and give it three bools for each “lock” or button needed to press. Add the door script to the door.

When player walks on that button, it sets the button value changing to true in the door script and check if all 3 locks are true as in pressed. If not, nothing happens. But if they are, the door opens.

You can use access other scripts inside a script by using GetComponent() for example.Unity - Scripting API: GameObject.GetComponent

And inside the ontriggerenter you might want to check what button you hit

  GameObject doorObject;
  DoorScript doorscript;

void Start()
{
  doorscript = doorObject.GetComponent<DoorScript>();
}
void OnTriggerEnter(Collider other)
 {

     if(other.gameObject.tag == "Button1")
     {
           doorscript.button1pressed = true;
     }


 }