// Use this for initialization void OnTriggerEnter(Collider other) { coins = other.transform.parent.GetComponent <Coins>(); coins.add(); GameObject.Destroy(this.gameObject); }