show variable number in gui box?

so i have a GUI box and it says “Current Money” and inside that i want the to show how much my Money variable has

heres the code :

var CurrentMoney : float = 20;
var MoneyGUI : GUI;

var Rigid50 : GameObject;
var Rigid100 : GameObject;
var Rigid150 : GameObject; // these are just for the rigidbody , so when i kill the rigidbody attached to this i get 150 money 

function Update (){


  if(CurrentMoney < 0){
  
    CurrentMoney = 0;
  }

  
  


}



function OnGUI (){

GUI.Box (Rect (10,10,100,90), "Current Money");

	if (GUI.Box(Rect (20,40,80,20), CurrentMoney)) { // THIS LINE

	}

}

GUI.Box() is not a button and therefore does not use an ‘if’ statement. Try this:

function OnGUI (){
	GUI.Box (Rect (10,10,100,90), "Current Money");
	GUI.Box(Rect (20,40,80,20), CurrentMoney.ToString());
}

Or, you could do as I do:

function OnGUI()
{
GUI.Box(Rect(10,10,100,90), "Current Money");
GUI.Box(Rect(20,40,80,20), "" + CurrentMoney);
}

How could i add money to the CurrentMoney variable from a other script?

var target : GameObject;

function start () {

target.CurrentMoney = + 30;

}

or what? :smiley: