Create hinge joint 2D by collision

I have a script which destroys a 2D hinge joint. To recreate the joint between two specific gameobjects I figured using a collision or trigger would work, but I cant seem to get any progress on recreating the joint (and thus allowing my script to destroy it on input key and start the process over). Any ideas on how to do this in script?

If you want to recreate the joint on collision, this should works:

void OnCollisionEnter(Collision other) {
		if (other.gameObject.tag == "YourOtherObjectTag") {
			HingeJoint myJoint = (HingeJoint)gameObject.AddComponent("HingeJoint");
			myJoint.connectedBody = other.rigidbody;
		}
}

void OnCollisionEnter2D(Collision2D other) {
if (other.gameObject.tag == “player”) {
Debug.Log (“hit”);
HingeJoint2D myJoint = (HingeJoint2D)gameObject.AddComponent(“HingeJoint2D”);
myJoint.connectedBody = other.rigidbody;
}
}

no collision is detected is now my issue. the debug log never shows anything. any thoughts?