Display message when collide with object?

Hi there, I’m new to Unity and JavaScript, basically I want to display a GUI I have set up in the Canvas called MessageBox when I collide with this object, I have the GUI deactivated but want to activate it when I collide with this object, If anyone has a solution Id really appreciate it. JavaScript please as I don’t know C#

import UnityEngine.UI;

function OnTriggerEnter (info:Collider) {  

var pickUpAudio : AudioSource = GetComponent.();  

 pickUpAudio.Play ();  
    PickUpSystem.itemCollect +=1;

transform.position = Vector3(0,-1000,0);

 yield WaitForSeconds (1.5);  

 Destroy (gameObject);

 var MessageBox : GameObject;

MessageBox.SetActive (true);
  
}

Sorry Can’t help you with Java.

But here’s what I see:

You are destroying the gameObject before SetActive.

//---------------------------------------------

Destroy (gameObject); //Put this at the bottom

var MessageBox : GameObject;

MessageBox.SetActive (true);

//-----------------------------------------------------

When you destroy the game object, the rest of the code will not run, because there is no object. Put the “Destroy (gameObject)” at the bottom, like this:

  //-------------------------------------------------
    
   var MessageBox : GameObject; 
   MessageBox.SetActive (true);
   Destroy (gameObject); //<<<<<
//------------------------------------------------------

Hope this helps. Also please use “code sample” [101010] icon, when you post code, so it’s easier to read.