Error Message constantly being printed

Greetings! I’m currently working in a score sistem based on “goal scoring”. Basically, the player needs to drag specific game objects to a defined area in order to increase the score value. Once the object reaches this area, it vanishes.

And the script works just fine, but whenever i start dragging the gameobjects after the first one is destroyed, i get this error:

DistanceJoint::loadFromDesc: Joint is
broken. Broken joints can’t be
ScriptDragRigidBody:Update() (at

Still, everything works normally. I only wish to know how damaging this error might be. So far the game still runs fine, but the error message is printed all the time.

This is the ScriptDragRigidBody script the code is refering to:

    var spring = 50.0;
var damper = 5.0;
var drag = 10.0;
var angularDrag = 5.0;
var distance = 0.2;
var attachToCenterOfMass = false;

private var springJoint : SpringJoint;

function Update ()
	// Make sure the user pressed the mouse down
	if (!Input.GetMouseButtonDown (0))

	var mainCamera = FindCamera();
	// We need to actually hit an object
	var hit : RaycastHit;
	if (!Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition),  hit, 100))
	// We need to hit a rigidbody that is not kinematic
	if (!hit.rigidbody || hit.rigidbody.isKinematic)
	if (!springJoint)
		var go = new GameObject("Rigidbody dragger");
		var body : Rigidbody = go.AddComponent ("Rigidbody") as Rigidbody;
		springJoint = go.AddComponent ("SpringJoint");
		body.isKinematic = true;
	springJoint.transform.position = hit.point;
	if (attachToCenterOfMass)
		var anchor = transform.TransformDirection(hit.rigidbody.centerOfMass) + hit.rigidbody.transform.position;
		anchor = springJoint.transform.InverseTransformPoint(anchor);
		springJoint.anchor = anchor;
		springJoint.anchor =;
	springJoint.spring = spring;
	springJoint.damper = damper;
	springJoint.maxDistance = distance;
	springJoint.connectedBody = hit.rigidbody;
	StartCoroutine ("DragObject", hit.distance);


function DragObject (distance : float)
	var oldDrag = springJoint.connectedBody.drag;
	var oldAngularDrag = springJoint.connectedBody.angularDrag;
	springJoint.connectedBody.drag = drag;
	springJoint.connectedBody.angularDrag = angularDrag;
	var mainCamera = FindCamera();
	while (Input.GetMouseButton (0))
		var ray = mainCamera.ScreenPointToRay (Input.mousePosition);
		springJoint.transform.position = ray.GetPoint(distance);
	if (springJoint.connectedBody)
		springJoint.connectedBody.drag = oldDrag;
		springJoint.connectedBody.angularDrag = oldAngularDrag;
		springJoint.connectedBody = null;

function FindCamera ()
	if (camera)
		return camera;
		return Camera.main;

This error is not harmful(i think), but i was able to fix it on my own project.

I think what is happening is that you are running both your destroy script AND this drag script at the same time.

Not sure if there is an easier way, but how i fixed it was to add a catch in my drag script to make it not run when my other destroy script would be running

if (hit.rigidbody.tag.Equals("Pickup")) //Triggers whenever your destroy script would
return;                                 //Exits the drag script