How do instantiate stuff as a child

I made this script and looked all over the internet and tried everything I saw but I always get a error even tho I know I set it up properly but yet I still get a error. Atm I am using this set up and getting this error. If you could answer in code and not a link I well like that a lot better.

read this before you assume its just fixing a error. 

Assets/Scripts/SpawnShips.cs(33,44): error CS0266: Cannot implicitly convert type `UnityEngine.Object' to `UnityEngine.GameObject'. An explicit conversion exists (are you missing a cast?)

here's the script 

using UnityEngine;
using System.Collections;

public class SpawnShips : MonoBehaviour {
	public string Help = "How many ships, type of ship, time befor start (keep it .5s or 1s";
	public Transform[] spawns;
	public GameObject[] SpaceShips;
	public Vector3[] positionArray = new [] { new Vector3(0f,0f,0f), new Vector3(1f,5f,5f) };
	private int currentPos = 0;
	private float time = 0;
	void Start () 
		InvokeRepeating("spawn", 0, 0.5f);
	void spawn()
		int ships = Mathf.RoundToInt(positionArray[currentPos].x);
		int TypeOfShip = Mathf.RoundToInt(positionArray[currentPos].y);
		int TimeBeforStat = Mathf.RoundToInt(positionArray[currentPos].z);

		time += 0.5f;
		if(time == TimeBeforStat)
			for(int i = 0; i < ships; i++)
				GameObject h;
				h = SpaceShips[TypeOfShip];
				GameObject instantiated = Instantiate(h.transform);            //instantiate the object
				instantiated.transform.parent = spawns*.transform;//assuming this script is attatched to the desired parent*
  •  		instantiated.transform.localPosition =;*
  •  	}*
  •  }	*
  • }*


Change line 41 (wher you instantiate) to

 Transform instantiated = Instantiate(h.transform) as Transform ;  //instantiate the object


 GameObject instantiated = Instantiate(h.transform) as GameObject;  //instantiate the object

Try this:

for(int i = 0; i < ships; i++)
                GameObject h = (Instantiate(SpaceShips[TypeOfShip],spawn_.position,spawn*.rotation) as GameObject);*_

_ h.transform.parent = spawn*.transform;

The code to instantiate a child is pretty straight forward

GameObject clone = (GameObject)Instantiate(prefab);
clone.transform.parent = transform;

I suspect you have other things going wrong in your convoluted code. What is the actual error you are getting? Include the exact text of the error message and the line number.

I would also strongly recommend rewriting this script from scratch. Its a bit of a mess to follow.

Use yourObject.transform.parent = parent