I am trying to work out why when this script runs, it spawns both objects? Sounds silly, but I was trying to spawn one or the other, well, eventually many, but in this example just one. When it runs both objects appear.
var randomNumber : int;
var floorTileNorm : GameObject;
function Start () {
randomNumber = Random.Range(1, 2);
if (randomNumber == 1);
Instantiate (floorTileNorm, Vector3(100,200,100),Quaternion.identity);
}
if (randomNumber == 2);
Instantiate (floorTileNorm, Vector3(400,200,100),Quaternion.identity);
Thanks for taking a look.
The problem is that you’re using " ; " after the if statements, so, it’s not interpreting that the above lines are about the statement.
So, it’s really instantiating both objects. Just remove the " ; " from after if, and you’ll be good to go. 
You have two problems here. The first is the structure of your code. On line 8, you have a ‘;’ at the end of your ‘if’ statement which terminates the ‘if’. In addition, your ‘}’ on line 11, closes off the ‘Start()’ function. The reason you get the second one is that your other code gets executed because of the way Javascript handles scripts in open code.
Another problem is that Random.Range() when used with integers is exclusive of the last number, therefore your code would only return 1…never 2. You may one something more like:
#pragma strict
var randomNumber : int;
var floorTileNorm : GameObject;
function Start () {
if (Random.value < 0.5) {
Instantiate (floorTileNorm, Vector3(100,200,100),Quaternion.identity);
}
else {
Instantiate (floorTileNorm, Vector3(400,200,100),Quaternion.identity);
}
}