How to disable scripts from other objects with the same script?

I have 2 rocks, once mined they drop an ore. If I mine 2 rocks and they both drop an ore, and I pick one up, my “Total ore” goes up by 2 cause they both have the same script that adds +1 to the total once picked.

How would I go on separating these scripts?

Hi Naiveca,

I am not 100% sure that I understand your set up correctly, but it sounds like your rocks have a script on them, that is waiting for the player to pick up any ore and increase the player’s ore count if this happens.

Should this be the case, I would recommend splitting your logic into two parts:

  1. The rocks have a script that is handling spawning the ore
  2. The ore has a script that will increase the player’s ore count by one when the player ‘picks it up’

This way every game object does its own thing and you could even have ore laying around that can be collected by the player without the need for it to be dropped by a rock to be collectable.