Picking up cubes

The code is supposed to let you pick up cubes by holding down your left mouse button, it works, but when you move your camera and let go, it doesn’t keep its momentum. Here is the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Pickup_cube : MonoBehaviour {

    //this decides when you are holding the cube
    public bool holding;

    void OnMouseDown()
    {
        holding = true;
    }

    void OnMouseUp()
    {
        holding = false;
    }

    void Update()
    //this decides what the cube will do when you are holding it
    {
        if (Input.GetButtonDown ("Fire2")) {
               
        }
        if (Input.GetButtonUp ("Fire2")) {
           
        }
        if(holding == true)
        {
            this.transform.SetParent(Camera.main.transform);
            Rigidbody Rigidbody = gameObject.GetComponentInParent<Rigidbody>( );
            Rigidbody.useGravity = false;
            Rigidbody.drag = 100;
            Rigidbody.isKinematic = false;
        }
        if(holding == false)
        {
            this.transform.parent = null;
            Rigidbody Rigidbody = gameObject.GetComponentInParent<Rigidbody>( );
            Rigidbody.useGravity = true;
            Rigidbody.drag = 0;
            Rigidbody.isKinematic = false;
        }
    }
}

when you setparent, you are moving the cube via translation, meaning to the rigidbody, there is no velocity change despite movement. with no velocity change there is nothing to decelerate from since as far as the rigibody was concerned there was no movement from forces.

A way to fake it is to add a force upon letting go based on the difference in position. You will have to track the position and compare it to the current position to get the difference.

Vector3 prevPos;//cached position

//calculating and applying the force
Vector3 dist = transform.position - prevPos;
float time = Time.deltaTime;
rigidbody.AddForce((dist/(time * time)) *rigidbody.mass);

//caching position
prevPos = transform.position

As a basic physics lesson:
speed = distance/time
acceleration = speed/time
force = mass * acceleration

Ill leave you to learn how force was derived from distance, time, and mass on your own time. In anycase this is merely an estimate and might not be accurate.

Moving a block via translation however is a bad idea, having a rigidbody object as a child of another object is worse.

Moving a block via translation would allow the block to move through walls, and most likely become unreachable, leaving the game unplayable if the block was essential to the game.

Having a child object with a rigidbody from experience makes the physics behaviour go haywire. i guess you have tried to mitigate this by increasing the drag to ludicrous amounts, but it is still a bad idea. I have no idea what causes it but it is nonetheless a bad idea.

What you want more likely is to use one of the Physics Joints and move it that way.