Score Count Bug

So i’m creating a pickup system where when i collect the pickup, it is destroyed and the score should increase by 1. But when i collect the pickup the score somehow increases by 2. And this only happens if i destroy the pickup. If i use gameObject.SetActive(false) to deactivate the pickup then the score increases by 1 like it should. So why is this happening?

`

From Unity Docs:

it will destroy the GameObject, all its components and all transform children of the GameObject. Actual object destruction is always delayed until after the current Update loop, but will always be done before rendering

Could be a syncing issue which may need a work around like telling the colliers to ignore eachother

Or you really are coming into contact twice.

Hey Guys i found the problem and it was a pretty silly one. The OnTriggerEnter code was attached to the player but i hadn’t enabled the “is Trigger” on the player itself. Instead i had enabled it on the pickup. :stuck_out_tongue:

Maybe you should try ‘++ui.count’ instead of ‘ui.count++’.
Also, I prefer to use ‘ui.count += 1’.