Door opens itself with no input

I am new to unity so I’ve been trying to create stuff without looking too much into a specific guide on how to make something. I am having difficulties making a door that opens when I’m in range of a hitbox and hit e. This is my code so far:

private bool inZone = false;

private void OnTriggerEnter(Collider other)
{
    if (other.tag == "Player")
    {
        inZone = true;
    }
}

private void OnTriggerExit(Collider other)
{
    if (other.tag == "Player")
    {
        inZone = false;
    }
}

void Update()
{
    if (inZone && Input.GetKeyDown(KeyCode.E))
    {
        door.SetBool("doorOpening", true);
        
    }

}

With this, the animation does work but what happens is that, when I run it, it instantly opens as if Im inside the box and pressing E, even tho the player is placed outside and I’m not hitting E. Maybe this is a dumb question but I am breaking my head with this, please help!

I assume that the door variable is the animator component? The code seems fine, the likely problem would be your animator controller’s default state is set to the open animation which would make it play on start. If this is the issue then you could just create a new idle state and set that as the default and transition from idle to open. If you’re using the animation component which I assume you aren’t because of the SetBool, then check that your animation component is not checked to play automatically. Hope this helps.