What you need to do is select your entity in the level editor and go to the entity tab, from there enter something into the PlayerInteractCallback field (like "InteractDoor")
Then go into your code for that level and type something like
void InteractDoor(string &in asEntity)
{
if(GetLocalVarInt("Door") != 1)
{
SetMessage("Message", "Message", 0);
}
else
{
}
}
In the above example lets say the variable goes to 1 when the player picks up the key. Anytime he interacts with it before the key the message will show, and anytime he interacts with it and he has the key nothing will happen.