Random Value Script

Can anyone take a look at this script, it used to work and gave a random number for each zone, but I'm trying to change it so it wont give the same random number twice for a zone. It's the logic from line 20 that giving problems, maybe because it does not loop again if the previous value is equal to the current value?

var zones : int[] = new int[4];
var previousZones : int[] = new int[4];

function Start ()
{
    var arr = new Array ();

    // Resize the array
    arr.length = 4;

    // Add data
    arr[0] = 1;
    arr[1] = 2;
    arr[2] = 3;
    arr[3] = 4;

// iterate through the array to give each zone a random number.
for (var i = 0; i <= 3; ++i)
    {

        var index = Random.Range(0,arr.length);
        if (previousZones *!= index)*
 *{*
 _zones *= arr[index];*_
 <em><em>previousZones _= zones*;*_</em></em> 
 <em><em>_*arr.RemoveAt(index);*_</em></em> 
 <em><em>_*}*_</em></em>
<em><em>_*}*_</em></em>
<em><em>_*}*_</em></em>
<em><em>_*function Update () {*_</em></em>
 <em><em>_*Debug.Log( "Zone 1 = " + zones[0] + " Zone2 = " + zones[1] + " Zone3 = " + zones[2] + " Zone4 = " + zones[3]);*_</em></em>
 <em><em>_*}*_</em></em>
<em><em>_*```*_</em></em>

Not sure why you are storing another array for previous zones when you have your zones array which tells you what the previous zone was.

var chosen : int[]; //This way you can set your initial zones in the editor
private var availableChoices : Array = new Array();

function Update() {
    shuffle();
}

function shuffle() {
    for(var i : int = 0; i < chosen.length;i++) availableChoices *= i+1;*
 *for(i = 0; i < chosen.length; i++) {*
 *var choice : int = Random.Range(0, availableChoices.length);*
 _if(chosen *== availableChoices[choice]) {*_
 _*if(availableChoices.length > 1) { //select something different.*_
 _*if(choice != 0) choice = 0;*_
 _*else choice = 1;*_
 _*}*_
 _*else if(chosen.length > 1) { //Only the first ones shuffled.*_
 _*var temp : int = chosen[i-1];*_
 _*chosen[i-1] = availableChoices[0];*_
 _*availableChoices[0] = temp;*_
 _*}*_
 _*}*_
 <em>_chosen *= availableChoices[choice];*_</em>
 <em>_*availableChoices.RemoveAt(choice);*_</em>
 <em>_*}*_</em>
 <em>_*var message : String;*_</em>
 <em>_*for(i = 0; i < chosen.length; i++)*_</em>
 <em><em>_message += "Zone " + (i + 1) + " = " + chosen *+ " ";*_</em></em>
 <em><em>_*Debug.Log(message);*_</em></em>
<em><em>_*}*_</em></em>
<em><em>_*```*_</em></em>