Instantiate Terrain Object as child of Empty Game Object

I realise this has been asked many times already, but I’ve just come from FOUR other threads with similar titles, tried what they said, and couldn’t get it to work.

I have a script attached to an empty Game Object (with box collider attached). I want to instantiate a terrain piece as a child of the object.

So far I have:

var tile;

tile = Instantiate (fHigh1, Vector3(r, 0, c), transform.rotation);

tile.transform.parent = this;

A multitude of different errors pop up with every combination I try.
I’ve also tried:

tile.transform.parent = transform;
tile.transform.parent = Transform;
tile.Transform.parent = transform;
tile.Transform.parent = Transform;
tile.transform.this = transform;

Help please :frowning:

I would think your error is there:

tile.transform.parent = this;

‘this’ represents the script not the object.

try

tile.transform.parent = transform;

The code below works for me (in C#):

public class Script : MonoBehaviour {
	public GameObject tile;
	void Start () {
		GameObject obj = (GameObject)Instantiate(tile,new Vector3(0,0,0),Quaternion.identity);
		obj.transform.parent =transform;
	}
}

Note: Since you are using UnityScript, if you have #pragma strict at the top var tile; should be var tile:GameObject;