NullReferenceExeption on OnCharacterControllerHit

In my game, when a character jumps on a certain object, it is supposed to do something. As the code follows, when the character jumps on a object, the character takes the parent’s name. Depending on the name, it will do something, but at the if… then… statement in the code, there is a NullReferenceExeption when the character jumps on anything.
Heres the code:

function OnControllerColliderHit (hit : ControllerColliderHit) {
	var name = hit.gameObject.transform.parent.name;
	if (name == "Thing") {
		Debug.Log("Yay!");
	}
}

Your code will will generate a null reference exception if the game object you collided with does not have a parent. If parent == null then your “parent.name” will generate the exception.