GUI disappears after changing values

I have this code:
#pragma strict

var balance=0;

function OnMouseDown() {
	balance=balance+5;
	Destroy (gameObject);
}
function OnGUI () {
	GUI.Label (Rect (10, 10, 100, 20), "$"+balance);
}

attached to a money gameObject so that I gain money when it is clicked. When running it however, the GUI works as intended until I click the gameObject. The gameObject disappears as intended but the GUI also disappears. What am I doing wrong and what can I do to fix it?

When you destroy game object, all its components, including scripts, are destroyed as well. So your script is destroyed, and OnGUI function cannot be executed.

If you want the text to be displayed all the time, then you have to move balance variable and OnGUI function to another script, attached to a different game object. And in your OnMouseDown function, you should update balance variable of this new script.