Help with Random clones

I want a Random.choice to determine what to clone so I put in
if(trigger){
let a = (random.choice(array)).clone
a.x = Something.x
a.y = Something.y
}
But it says Cannot clone Undefined

If what you put into the array is not a clip object on the current frame, then it will give you undefined. Also, it should be .clone();

okay what do I put into the array to make it not say undefined? :thinking:

If you want a random clone from the “already made” clones to go to an x and y, use this:

if(trigger){
let a = random.choice(this.clones);
a.x=Something.x;
a.y=Something.y;
}

If you want a new clone to go to an x and y position, use “clone()” (like Jovanny mentioned)

if(trigger){
let a=this.clone();
a.x=Something.x;
a.y=Something.y;
}
1 Like

Ok, lets say that you have 3 clips to be cloned in your current frame…

  • First name them…
    enemy1
    enemy2
    enemy3

Then, just put their name as follows:
let a = (random.choice([enemy1,enemy2,enemy3])).clone();

1 Like

OH my goodness im not smart i didn’t Put the square brackets around the array, thank you!

1 Like