It does not add money to player when it should ?

here is the code

` bool intrigger;

private void OnTriggerEnter(Collider other)
{

    intrigger = true;

}
private void OnTriggerExit(Collider other)
{
    intrigger = false;
}
private void Update()
{
    if(intrigger)
    {

        if (Input.GetKeyDown(KeyCode.G))
        {

            money = money + moneyonground;
            Debug.Log(money);

            gameObject.SetActive(false);
                       }
    }
}

}
`

when i am in trigger of money (on ground) when i press g it says 5 there is no problem until here: when i am entering other money’s trigger it still says 5 ? but is should say 10 ? can you help me

are you sure the moneyonground variable inside your update gets the correct value ?
check it with a Debug.Log("moneyonground " + moneyonground);

Where is the variable money stored? if its just on the trigger item then you are just updating the amount on the item and each item would have their own amount. make sure the money variable is not stored on the trigger item and is on the script of the object causing the trigger.

example… sorry but is in JS.
//////coin script
var playerObject : gameObject;
var moneyonground : int = 5;
var intrigger : boolean = false;

private void OnTriggerEnter(Collider other) {
intrigger = true;
playerObject = other.gameobject;}

private void OnTriggerExit(Collider other) { intrigger = false; }

function Update() {
if(intrigger) {
if (Input.GetKeyDown(KeyCode.G)) {
playerObject.SendMessage(“AddMoney”,moneyonground);
gameObject.SetActive(false);
}
}
}

//// Add to player script
var money : int = 0;

function AddMoney(amount : int){
money = money + amount;
Debug.Log(money);
}