How do I destroy a single object that shares a tag name with other objects?

So I have a scene where the player has to collect some fuses to get the power on. The problem is that all the fuses are destroyed whenever I pick up a fuse in-game. I don’t want to create a separate tag for each fuse, and I want to avoid OnMouseOver due to its jankiness. Is there a way I can keep my fuses tagged the same and avoid OnMouseOver while only destroying the fuse I am trying to pick up?

Here’s the script:

float distance;

[SerializeField] string tagName;

[SerializeField] float reach;

[SerializeField] GameObject playerGuy;
[SerializeField] GameObject interactionImage;

[SerializeField] ItemData _itemData;
[SerializeField] InventoryViewController inventoryData;

void Update()
{
    distance = PlayerCasting.DistanceFromTarget;

    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

    RaycastHit hit;
    if (Physics.Raycast(ray, out hit))
    {
        Transform selection = hit.transform;
        if (selection.CompareTag(tagName))
        {
            if (distance <= reach && !SelectPuzzle.isPuzzling)
            {
                interactionImage.SetActive(true);

                if (Input.GetButtonDown("Interact"))
                {
                    if (!InventoryViewController.inventoryFull)
                    {
                        inventoryData.OnPickedUpItem(_itemData);
                        interactionImage.SetActive(false);
                        Destroy(gameObject);
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }
    }

    if (distance > reach)
    {
        interactionImage.SetActive(false);
    }
}

I don’t believe this is a tag issue, as you’ve handled most of the logic to pinpoint a specific object, but you don’t appear to use it in the end. On line 35, you are destroying the gameobject you have this script attached to, instead of the selection object I assume you wish to destroy.

 Destroy(gameObject);

Is that on purpose?

Instead of using Destroy(gameObject) to destroy the object, you can use Destroy(selection.gameObject) to only destroy the object that you are interacting with. This will allow you to keep all fuses tagged the same and avoid using OnMouseOver.

Here’s how the updated script would look like:

float distance;
[SerializeField] string tagName;
[SerializeField] float reach;
[SerializeField] GameObject playerGuy;
[SerializeField] GameObject interactionImage;
[SerializeField] ItemData _itemData;
[SerializeField] InventoryViewController inventoryData;

void Update()
{
distance = PlayerCasting.DistanceFromTarget;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;

if (Physics.Raycast(ray, out hit))
{
    Transform selection = hit.transform;
    if (selection.CompareTag(tagName))
    {
        if (distance <= reach && !SelectPuzzle.isPuzzling)
        {
            interactionImage.SetActive(true);
            if (Input.GetButtonDown("Interact"))
            {
                if (!InventoryViewController.inventoryFull)
                {
                    inventoryData.OnPickedUpItem(_itemData);
                    interactionImage.SetActive(false);
                    Destroy(selection.gameObject);
                }
                else
                {
                    return;
                }
            }
        }
    }
}

if (distance > reach)
{
    interactionImage.SetActive(false);
}

}

Note that selection.gameObject is used instead of gameObject to only destroy the object that was hit by the raycast.