# Create Clone from an Array

**URL:** <https://forum.babylonjs.com/t/create-clone-from-an-array/10900>\
**Category:** Questions\
**Created:** [May 16, 2020, 9:36pm UTC](https://forum.babylonjs.com/t/create-clone-from-an-array/10900 "2020-05-16T21:36:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anderson34](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@Anderson34](https://forum.babylonjs.com/u/Anderson34)\
**Post date:** [May 16, 2020, 9:36pm UTC](https://forum.babylonjs.com/t/create-clone-from-an-array/10900/1 "2020-05-16T21:36:58Z")

</div>

Hello everyone,

There are two issues in the PG below that I am currently unable to solve.  
[https://www.babylonjs-playground.com/#ZQLA5C#6](https://www.babylonjs-playground.com/#ZQLA5C#6)

1. For each clone (“B”), create a **random** parented cube above it from **arrayH** (which holds 3 different meshes). Here’s an example where this almost works–the cube is random (red, green, or blue), but every yellow box clone has the **same** random cube: [https://www.babylonjs-playground.com/#ZQLA5C#4](https://www.babylonjs-playground.com/#ZQLA5C#4). The goal is for every clone to have a **different** random red, blue, or green cube.

2. This might not be possible, but I’m hoping that each clone will respond differently based on which cube it gets. For instance, if a clone is the parent of a “redCube,” then it will start rotating. Or, if it gets a “blueCube,” then the clone will start moving along the x axis.

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gijs/32/44_2.png) [@Gijs](https://forum.babylonjs.com/u/Gijs)\
**Post date:** [May 17, 2020, 12:38am UTC](https://forum.babylonjs.com/t/create-clone-from-an-array/10900/2 "2020-05-17T00:38:47Z")

</div>

Hi Anderson,

Here is a playground as you describe, in the loop it creates a new instance of one of the original three cubes, and sets the parent to `cloneB`, then it adds on render code:

[https://www.babylonjs-playground.com/#ZQLA5C#8](https://www.babylonjs-playground.com/#ZQLA5C#8)

---

<div class="post-metadata">

**Author:** ![Anderson34](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@Anderson34](https://forum.babylonjs.com/u/Anderson34)\
**Post date:** [May 17, 2020, 3:56am UTC](https://forum.babylonjs.com/t/create-clone-from-an-array/10900/3 "2020-05-17T03:56:16Z")

</div>

Hello @Gijs, and thanks for helping with this, I really appreciate it! 😃 👍
