Need help with the pickup mechanic!

This is the script:`
{
public static Item Instance;

public GameObject item;
public GameObject ItemHandSlot;

public Camera mainCam;

public static bool isPickedUp;
public bool isPicked;

public float range;

Rigidbody rb;
Collider cd;
RaycastHit hit;
// Start is called before the first frame update
void Start()
{
    Instance = this;

    ItemHandSlot = GameObject.Find("ItemHandSlot");
    mainCam = Camera.main;
    rb = GetComponent<Rigidbody>();
    cd = GetComponent<Collider>();
}

// Update is called once per frame
void Update()
{
    Ray ray = new Ray(mainCam.transform.position, mainCam.transform.forward);
    Debug.DrawRay(ray.origin, ray.direction * range);

    if(Physics.Raycast(ray, out hit, range))
    {
        if (hit.collider.gameObject == item)
        {
            if (!isPicked)
            {
                PickUp();
            }
        }
    }
    else
    {
        Drop();
    }
    if (isPickedUp)
    {
        item.transform.parent = ItemHandSlot.transform;
        item.transform.position = ItemHandSlot.transform.position;
        item.transform.rotation = ItemHandSlot.transform.rotation;
        rb.useGravity = false;
        cd.enabled = false;
    }
    else
    {
        item.transform.parent = null;
        rb.useGravity = true;
        cd.enabled = true;
    }

}
public void PickUp()
{
    if (!isPickedUp && Input.GetKeyDown(KeyCode.E))
    {
        isPickedUp = true;
        isPicked = true;
    }
}
public void Drop()
{
    if (isPickedUp && Input.GetKeyDown(KeyCode.E))
    {
        isPickedUp = false;
        isPicked = false;
    }
}

}`

The problem I’m having is that when I pickup the item, I pickup all items that use this script.

Thank you for the help in advance.

Id try using hit.gameObject.tag == “itemtag” for the pickup instead of trying to pickup the one you have set as a variable, that’s probably the issue.