Pick something up with name - ontrigger

I’m making something and want to pick up something.
When you pick it up you can see it in the inventory.
That part works but it doesn’t detect it.

(This script is on the player)
This is what I have now, does anybody know why it doesn’t work?

  • yes the objects have a trigger

private void OnTriggerEnter(Collider other)
    {
        if ((other.gameObject.name == "NAME1") && (Input.GetButtonUp("Fire2")))

        {
            IMAGE1.GetComponent<Image>().sprite = IMAGE2;
     
        }

try putting the script on the object with the trigger instead