Destroy box and show image

Hi,

I got the following situation. There’s a box on my scene. If the player touches the box, the box will be deleted and an image has to appear on the screen.

So when I play the game and touch the box, the box will be destroyed but the image won’t appear on the screen. However, if I take out the line to destroy the box, it does work. But I need the box removed too!

This is my script right now:

var show : boolean;
var GUI_Key : Texture2D;

function Start(){
	show = false;
}

function OnTriggerEnter (other : Collider) {
	
	//Get the item by touching it, then destroy the item
	Destroy(gameObject);
	
	//Put item image on screen
	show = true;
}

function OnGUI () {
	if(show){
		GUI.DrawTexture(new Rect(10,10,40,39), GUI_Key);
	}
}

Which gameobject are you destroying? Are you destroying the gameobject which has the GUI Texture as its own component?

u destroy the object with the script. so it won’t run the script after u destroy it. attach the gui scrpit on an emptygame object or on ur gui object but leave ur destrooy function on that cube. and before u destroy it change the variable on ur gui script.

function OnTriggerEnter (other : Collider) {
gameObject.Find("GuiObject").GetComponent("guiscript").show = true;
Destroy(gameObject);
}