Pick up script bug

I have a couple of bugs that I can’t seem to fix:

  1. When I try to pick up an item I pick up all of the items that my script is attached to (and that are supposed to be able to be picked up).
  2. The gravity doesn’t turn off when I try to pick up an item.
  3. I can’t pick up 1 of the items that this script is attached to (, I can pick up the other ones work though).
  4. The colliders on the children of the items don’t turn off when I try to pick up the item.

The PickUpItem() and DropItem() voids are called in Update() when you press the E key.

Any help is appreciated.

This is my script:

using UnityEngine;
using System.Collections;

namespace CarryingItems {

    public class PickUp : MonoBehaviour {
            
        private float RayCastLength = 2.15F;
        public LayerMask RayMask;
              
        public float OffsetDropPosition = 2;
      
        private GameObject CarryableObject;
        private GameObject CameraMain;
        private GameObject Character;
        private GameObject Handle;
        private GameObject HandleExtra;
        private GameObject BladeHolder;
        private GameObject Blade;
          
        private bool ItemPickedUp;
              
        void Awake() {
            CarryableObject = this.gameObject;
            CameraMain = GameObject.Find("MainCamera");
            Character = GameObject.Find("Character");
            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")) {
                ItemPickUp();
                ItemDrop();
            }  
        }
      
        void ItemPickUp() {
            if(ItemPickedUp == false) {
                if (Physics.Raycast(CameraMain.transform.position, CameraMain.transform.forward, RayCastLength, RayMask.value)) {
                    CarryableObject.transform.parent = Character.transform;
                    CarryableObject.transform.position = new Vector3(Character.transform.position.x + 1, Character.transform.position.y + 1, Character.transform.position.z + 1);
                    CarryableObject.transform.rotation = Character.transform.rotation;
                    CarryableObject.GetComponent<Rigidbody>().useGravity = false;
                    ItemPickedUp = true;
                    if(Handle != null){
                        Handle.GetComponent<Collider>().enabled = false;
                    }
                    if(HandleExtra != null){
                        HandleExtra.GetComponent<Collider>().enabled = false;
                    }
                    if(BladeHolder != null){
                        BladeHolder.GetComponent<Collider>().enabled = false;
                    }
                    if(Blade != null){
                        Blade.GetComponent<Collider>().enabled = false;
                    }
                }
            }
        }
      
        void ItemDrop() {
            if(ItemPickedUp == true){
                CarryableObject.transform.parent = null;
                CarryableObject.transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z + OffsetDropPosition);
                CarryableObject.transform.rotation = Character.transform.rotation;
                CarryableObject.GetComponent<Rigidbody>().useGravity = true;
                ItemPickedUp = false;
                if(Handle != null){
                    Handle.GetComponent<Collider>().enabled = true;
                }
                if(HandleExtra != null){
                    HandleExtra.GetComponent<Collider>().enabled = true;
                }
                if(BladeHolder != null){
                    BladeHolder.GetComponent<Collider>().enabled = true;
                }
                if(Blade != null){
                    Blade.GetComponent<Collider>().enabled = true;
                }
            }  
        }
    }
}

If that’s on all of the scripts, that’s one of the problems.
I don’t know what CarryableObject is (I Guess the game object you’re picking up?).

Maybe if you raycast when ‘e’ is pressed, and if you hit something, check that “hit (something)” and see if it has a Component for CarryableObject (or whatever you want to call it). If that component is found, then pick it up.
I think that would be a lot simpler.