how to instantiate a GUI text box for end of

this is the script i put on the empty game object with a box collider so that when the spaceship(which also has a box collider) hits collides with the invisible box collider it should make a GUI text box appear saying "You Win!".....but it's not working...I'm guessing I probably should have a OnGUI function somewhere but I'm not sure where...I'm new to this whole Unityscripting thing...

// A spaceship // - instantiates a GUI text box declaring your a winner when hitting a invisible box collider var GameEnd : (10,10,100,100),"You Win!");

function OnCollisionEnter(collision : Collision) { Instantiate(GameEnd); }

Since you mention an invisible box, I would probably use a Trigger instead of a Collider. Set your box collider to isTrigger and try the following script (attach to the box).

You have a boolean variable which determines whether the trigger has been entered. If this variable is true, it will display the win-message within the OnGUI function. You can also add more stuff below the win-message like advance to a new level, etc.

private var triggerEnd : boolean;

function OnTriggerEnter (other : Collider) {

    	triggerEnd = true;


    function OnGUI () {

    if (triggerEnd == true) {

    	GUI.Box(Rect (10, 10, 100, 20), "Hello World!");