Picking up every item...

I have this code to pick up and hold items, but whenever I try to pick up one of the items I can pick up, I pick up all of the items. Like this:

This is my script.

using UnityEngine;
using System.Collections;

#pragma warning disable 0414

namespace CarryingItems {

    public class PickUp : MonoBehaviour {
    
        private float RayCastLength = 2.15f;
        public LayerMask RayMask;
    
        private float OffsetDropPosition = 2;
    
        // The parent.
            private GameObject UtilityProps;

        // The object I'm trying to carry.
            private GameObject CarryableObject;

        // Where to place the item.
            private GameObject Hand;
    
        // The character and camera.
            private GameObject Character;
            private GameObject CameraMain;
    
        // The children the objects consist of.
            private GameObject Handle;
            private GameObject HandleExtra;
            private GameObject BladeHolder;
            private GameObject Blade;
    
        private bool ItemPickedUp;
    
        void Awake() {
            UtilityProps = GameObject.Find("UtilityProps");
            CarryableObject = this.gameObject;
            Hand = GameObject.Find("ItemHand");
            Character = GameObject.Find("PlayerCharacter");
            CameraMain = GameObject.Find("MainCamera");
            Handle = this.gameObject.transform.GetChild(0).gameObject;
            HandleExtra = this.gameObject.transform.GetChild(1).gameObject;
            BladeHolder = this.gameObject.transform.GetChild(2).gameObject;
            Blade = this.gameObject.transform.GetChild(3).gameObject;
        }    
    
        void Start() {
            ItemPickedUp = false;
        }
    
        void Update() {
            if (Input.GetKeyDown("e")) {
                if(ItemPickedUp == false) {
                    ItemPickUp();
                }
                else if(ItemPickedUp == true){
                    ItemDrop();
                }
            }        
        }
    
        void ItemPickUp() {
            if (Physics.Raycast(CameraMain.transform.position, CameraMain.transform.forward, RayCastLength, RayMask.value)) {
                CarryableObject = this.gameObject;
                CarryableObject.transform.parent = Character.transform;
                CarryableObject.GetComponent<Rigidbody>().useGravity = false;
                CarryableObject.GetComponent<Rigidbody>().isKinematic = true;
                CarryableObject.transform.position = Hand.transform.position;
                CarryableObject.transform.rotation = Hand.transform.rotation;
                ItemPickedUp = true;
            
                Handle.GetComponent<Collider>().enabled = false;
                HandleExtra.GetComponent<Collider>().enabled = false;
                BladeHolder.GetComponent<Collider>().enabled = false;
                Blade.GetComponent<Collider>().enabled = false;
            }
        }
    
        void ItemDrop() {
            CarryableObject.transform.parent = null;
            CarryableObject.transform.position = CameraMain.transform.position + CameraMain.transform.forward*OffsetDropPosition;
            CarryableObject.transform.rotation = Character.transform.rotation;
            CarryableObject.GetComponent<Rigidbody>().useGravity = true;
            CarryableObject.GetComponent<Rigidbody>().isKinematic = false;
            ItemPickedUp = false;
        
            Handle.GetComponent<Collider>().enabled = true;
            HandleExtra.GetComponent<Collider>().enabled = true;
            BladeHolder.GetComponent<Collider>().enabled = true;
            Blade.GetComponent<Collider>().enabled = true;
        }
    }
}

It will pickup anything with that script on as the pickup code runs in update and e is pressed.

You need to either some method to determine if the player is close enough to an object they can pick up.

How would I get about to doing that?

Well you are raycasting for no particular reason it seems. You could raycast instead from the camera pos and check what object the player is looking at.

I’m already doing that right? The raycast is starting from the camera, the length is 2.15 which is how close you at least have to be to pick it up, and a layermask for the layer I put on the object that I can carry.

No, you are sending out a raycast and doing nothing with it. You would need to read the information back from the cast to find out if it hit anything.