hit.gameObject.AddComponent not working

Hi,

I would like to add a configurable joint to the rigidbody that the raycast is hitting but when I type hit.gameObject.AddComponent … it doesn’t recognize the statement. What am I doing wrong ?

My code :

void Update() {

		if(Input.GetMouseButtonDown (1)){
		
			Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
			RaycastHit hit;

			if (Physics.Raycast(ray, out hit, 100)){
				Debug.DrawLine(ray.origin, hit.point, Color.cyan);

				if(hit.rigidbody != null){

					ConfigurableJoint joint = hit.gameObject.AddComponent<ConfigurableJoint>();
					joint.xMotion = ConfigurableJointMotion.Locked;
					joint.yMotion = ConfigurableJointMotion.Locked;
					joint.zMotion = ConfigurableJointMotion.Locked;
					joint.angularXMotion = ConfigurableJointMotion.Free;
					joint.angularYMotion = ConfigurableJointMotion.Locked;
					joint.angularZMotion = ConfigurableJointMotion.Locked;
					joint.angularXDrive = new JointDrive
					{
						mode = JointDriveMode.Velocity,
						maximumForce = 10f,
						positionDamper = 0f,
						positionSpring = 0f
					};
					joint.breakForce = 20;
					joint.breakTorque = 10;
					joint.enableCollision = true;

				}
			}
		}
	}

ConfigurableJoint joint = hit.collider.gameObject.AddComponent();