What is wrong with my Chest script?

What is wrong with my Chest script?

I'm making an RPG in Unity3D and I am trying to make a script for a chest to open. So I built this script! But it doesn't work. I just want some help fixing this script.
#pragma strict
var Text : GameObject;
var OpenedChest : GameObject;
var CurrentChest : GameObject;

function OnTriggerEnter()
{
    Text.SetActive(true);
    if (Input.GetKeyDown("e"))
    {
        CurrentChest.SetActive(false);
        OpenedChest.SetActive(true);
    }
}

function OnTriggerExit()
{
    Text.SetActive(false);
}

I get no compiler errors. When I go into the collider that triggers the text, that works, but what doesn't is when I press E to open the chest. It doesn't activate the other chest. What is wrong with my script? 

Solutions/Answers:

Answer 1:

The issue in your code is that you only check for the key press in the OnTriggerEnter function, which only gets called when the collider enters the trigger. What you probably want to do instead is check for the keypress inside the OnTriggerStay function, which gets called while the collider lies inside the trigger.

Answer 2:

Is the script attached to the game object of one of the two chests CurrentChest and OpenChest? Then keep in mind that deactivating a game object also deactivates all scripts attached to it. That means any events on them won’t fire anymore. You likely only want to disable specific components of the chests.

References