- Home /
Question by
Ryan Mayer · Feb 06, 2011 at 04:44 AM ·
gui
Gui Counter wont count up at all
My Gui text counter wont count up it just stays at the set variable and when i go to collect the coin and the object disappears the counter stays at 0 can anyone help me?
script i used on the object:
static var money = 0;
function OnTriggerEnter( hit : Collider )
{ if(hit.gameObject.tag == "worm")
{ money = money + 1; Destroy(gameObject);
} }
and this is the script i used on the counter itself:
var Counter : int = 0;
static var money = 0; function Update () { guiText.text = "You have : " + money; }
If anyone can help me that would be great!
Comment
Looks like each script has its own money variable. You want the second script to reference FirstScript.money (or whatever the first script is called).
Your answer
![](https://koobas.hobune.stream/wayback/20220613103027im_/https://answers.unity.com/themes/thub/images/avi.jpg)