How do i make a text box appear on screen after a chest has been opened?

Hi, ive made a chest animation triggered when a player reaches the chest that it opens up, i now want to make it so once this animation is triggered a text box will appear saying what you received out of the chest.

How do i go about doing this?

This is the script i already have in place incase it is needed.

  function OnTriggerEnter (Player : Collider) 
  {  
    animation.Play("Take 001");
  }

Hi,

If you want to draw something on GUI, you can use the OnGUI method for GUI drawing.

see if this sample helps (someone help to port it to JS for him?) :

bool displayMessage = false;

void OnTriggerEnter ( Collider Player )
{
    animation.Play("Take 001");
}

void OnGUI ( )
{
    if ( displayMessage )
    {
        GUI.Label(new Rect(Screen.width * 0.5f - 50f, Screen.height * 0.5f - 10f, 100f, 20f), "Testing");
    }
}

Make this a seperate script on the same object...

function OnGUI () {
    GUI.Label (Rect (10, 10, 100, 20), "You picked up a pick ax!");
}

Then....

  function OnTriggerEnter (Player : Collider) 
  {  
    animation.Play("Take 001");
    GetComponent(SHOWMESSAGE).enable = true;
    yield WaitForSeconds(3);
    GetComponent(SHOWMESSAGE).enable = false;

  }

Check out how to use GetComponent: http://unity3d.com/support/documentation/ScriptReference/Component.GetComponent.html

Good luck!

TO _ JAVA

displayMessage = false;

function OnTriggerEnter (Player : Collider) {
{
    animation.Play("Take 001");
    displayMessage = true;
    yield WaitForSeconds(3);
    displayMessage = false;
}

function OnGUI ( )
{
    if ( displayMessage )
    {
        GUI.Label(new Rect(Screen.width /2, Screen.height / 2, 200, 200), "Testing");
    }
}

Ignore mine, use his, but this can work I think... Not the best when not on my computer.

I had the problem i mentioned in the comments above with the code you supplied, so i made a few alterations so there were no errors and i could get in play mode, but now the text just appears from the start and doesnt dissapear rather than appearing when the animation is triggered.

heres the new code ive had to use so it said there were no errors. changes i had to make were,

function OnTriggerEnter (Player : Collider) {
                to
function OnTriggerEnter (Player : Collider) 

it didnt like the extra { at the end because it wasnt attached to anything, when i tried just adding another one of them at the end it caused more errors. ALSO

if ( displayMessage )
       to
if ( "displayMessage" ) 

im guessing these changes are the reason it doesnt appear at the right time but it was the only way to remove the errors. Is there any help you can give to correct this so it appears at the right time when the animation is triggered?

Thanks