Random.Range Spawner

I’m trying to make 1 of 3 monster to spawn randomly but this code spawns all of them at the same
time.

var valo : GameObject;
    var monster1 : GameObject;
    var monster2 : GameObject;
    var monster3 : GameObject;        
    
    
    function Start(){
     Time.timeScale = 1;
    
     yield WaitForSeconds(1);
     
     particleEmitter.emit = false;
     
     valo.active = false;
     
     yield WaitForSeconds(1);
     
     var chance =(Random.Range(1, 4));
     
     if(chance == 1){
     monster1.SetActiveRecursively(true);
     }
         else if(chance == 2){
     monster2.SetActiveRecursively(true);
     }
         else if(chance == 3){
     monster3.SetActiveRecursively(true);
     }
         
         
     }

That code isn’t spawning anything (it is not doing an Instantiate) - I presume your 3 monsters are already in the scene (if they are all appearing then I would imagine that they are all active and that this code just sets them active again - which won’t do much).

You could try this in addition:

function Awake() {
     monster1.SetActiveRecursively(false);
     monster2.SetActiveRecursively(false);
     monster3.SetActiveRecursively(false);
}

Which would ensure that they were all deactivated.

EDIT
The problem was that the script was attached to more than one object.