Noob Problem with my Script

Hello!

The following Code is part of my Tiling Script, “randomgameobject” is a list of prefabs. Now my problem: When one of my prefabs has a parent with childs, I get the error: There is no Renderer attached to “parent within the prefab” gameobject. Any suggestions?
My Script:

GameObject randomgameobject = Platforms [Random.Range (0, Platforms.Length)];




		// First find a center for your bounds.
		Vector3 center = Vector3.zero;
		
		foreach (Transform child in randomgameobject.transform)
		{
			center += child.gameObject.renderer.bounds.center;   
		}
		center /= randomgameobject.transform.childCount; //center is average center of children
		
		//Now you have a center, calculate the bounds by creating a zero sized 'Bounds', 
		Bounds bounds = new Bounds(center,Vector3.zero); 
		
		foreach (Transform child in randomgameobject.transform)
		{

			bounds.Encapsulate(child.gameObject.renderer.bounds);   
		}

		float size = bounds.size.x;

Look into using: Unity - Scripting API: Component.GetComponentsInChildren

If it cannot find the component, when it’s definately there, it’s more than likely not looking recursively through the child objects.