Instatiate randomly along a vector

Hi, I’m new to Unity and I’m trying to get prefabs to only instatiate randomly along the X axis/vector 3 but I have no idea how to go about it. This is the code I’ve got at the moment:

var thePrefab : GameObject;

function Instantiate () {

	var instance : GameObject = Instantiate(thePrefab, transform.position, transform.rotation);

}

This makes the prefabs instatiate in the same place as the empty object I put the script in, but I’d like them to only respawn randomly along the X axis/vector 3. Can anyone help me?

Get the empty object’s position and add a random value to the x coordinate, then instantiate at this point:

var thePrefab : GameObject;
var range: float = 10; // set the +/- range around the empty object

function Instantiate () {
    var pos = transform.position; // get this object's position
    pos.x += Random.Range(-range, range); // add a random x offset around it
    var instance : GameObject = Instantiate(thePrefab, pos, transform.rotation);
}

You can move along the axes of the current transform with Transform.Translate and get the random component with Unity’s Random function. As an example:

var newTransform = transform.position;
newTransform.Translate(Vector3.right * Random.Range(-10.0, 10.0));
var instance : GameObject = Instantiate(thePrefab, newTransform, transform.rotation);