HELP with scripting where GUI is involved

I have a section of code set up which is making the text appear, but it is appearing as soon as i press play rather than when the animation is triggered, hoping someone can help me sort this problem out, ill post my code below.

Thanks in advance for any help offered.

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.5, Screen.height / 2, 200, 200), "You received 5gp");
     }
}

2 Answers

2

At the top where you say:

displayMessage = false;

it should say:

var displayMessage = false;

and whereit says:

 if ( "displayMessage" )

it should just say:

if (displayMessage)

Travis, this site is for helping unity developers when they have a real question, not for asking questions that have already been answered http://answers.unity3d.com/search?q=gui+text+size and are easy to look up http://unity3d.com/support/documentation/Components/GUI%20Scripting%20Guide.html

change if ( "displayMessage" ) to if ( displayMessage )