find parent of a collider

hi!
i have the following raycast, that sets the collider that was hit as the target:
but i dont want to be the target the collider. i want it to be the parent gameobject of the collider.
i have tried to do it with one of the outcommented lines. but they dont work.

public GameObject target;
void FindTarget ()
{

	RaycastHit hit;
	Ray ray = new Ray();
	ray.origin = transform.position;
	ray.direction = Vector3.forward;

	if (Physics.Raycast(ray, out hit, maxRange))
	{
		Debug.DrawLine(ray.origin, hit.point);
		target = hit.collider.gameObject;
		//target = target.parent;
		//target = target.gameObject;
	}
}

}

I’m not sure if this is what you’re asking, but to find a parent you have to traverse the Transform hierarchy.

target = hit.collider.transform.parent.gameObject;

That little snippet will grab the collider’s transform, get it’s parent and assign the parent’s gameObject to the variable.

Is that what you’re looking for?

Cheers,

==