Trouble with rigidbody.constraints

Sorry, newbie here,

I have a gameobjectA that after it gets dragged close to another gameobjectB the gameobjectA positions itself at a certain Vector3. Once this has been achieved I would like the gameobjectA to freeze its x, y, and z positions. Here’s the code I have and it was the best I could make from the API guide. Thanks for any help.

	var distance : float;
	//Check distance between both objects
	distance = (GameObject.Find("building1").transform.position - GameObject.Find("block1").transform.position).magnitude;

	//If distance is less than X
	if(distance < 1)
    	var constraints : RigidbodyConstraints;
    	//snap first object to the other objects position
    	GameObject.Find("building1").transform.position = Vector3(-35.7,0,-9.21);
    	rigidbody.constraints = RigidbodyConstraints.FreezePositionX;
    	rigidbody.constraints = RigidbodyConstraints.FreezePositionY;
    	rigidbody.constraints = RigidbodyConstraints.FreezePositionZ;

You should store the transform for “building1” in a variable

private var b1:Transform;

function Start()
    b1= GameObject.Find("building1").transform;

then later on in the code, wherever

if(distance < 1)
    b1.position = Vector3(-35.7,0,-9.21);

This is under the assumption that you want to freeze building1’s position where it is. I stored building1’s transform so you dont have to constantly have to search the ENTIRE scene each time you want to reference it. RigidbodyContraints can freeze the entire position if need be, as i did above. Same is true of rotation.