Set all Children Rigidbody Constraints C#

I’m trying to trigger removal of all constraints on children rigidbodies when an object collids with the parent trigger. I’m using the following code:

void OnTriggerEnter(Collider col){
	if(col.tag=="EnemyType1"){ 
		foreach (Transform child in transform)
		{
		Debug.Log ("im a child");
		if (transform.gameObject.rigidbody!=null)
		transform.gameObject.rigidbody.constraints = RigidbodyConstraints.None;
		}
  	 } 
}

This logs “im a child” for each child gameObject but does not remove the constraints on the rigid-bodies. Any idea what I’m doing wrong?

Don’t you need to use if(child.gameObject)… and child.gameObject.rigidbody…