I need help with this pickup script....

I’ve got this pickup script in the works, but no matter what I do i can’t fix it.

var moneydisp : GUIText;
var money = 20;

function Update () 
{
    moneydisp.text = "Bananas! : "+ money;
}

function OnTriggerEnter()

    {   
        Debug.Log("You have picked up a banana");
        Destroy(gameObject);
        money++;
    }

So obviously, this is supposed to add one when you hit a banana trigger, and that’s not happening. Also, in the inspector, when I set the money variable to 1, the guitext still prints 20, and still won’t add. I need some guidance on how to get this to work, it’s a pretty key script in my project.

because you destroy the object where this script is attached before the variable money can add anything i suppose

Exactly, comment out the Destroy(gameObject); and it works fine. If at all you need to remove any object from the scene, then start looking at Prefabs.