# Picking random sprite out of a group of the same sprites

**URL:** <https://forum.makecode.com/t/picking-random-sprite-out-of-a-group-of-the-same-sprites/43637>\
**Category:** Help\
**Created:** [April 26, 2026, 1:26am UTC](https://forum.makecode.com/t/picking-random-sprite-out-of-a-group-of-the-same-sprites/43637 "2026-04-26T01:26:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![plierplierplier](https://avatars.discourse-cdn.com/v4/letter/p/3d9bf3/32.png) [@plierplierplier](https://forum.makecode.com/u/plierplierplier)\
**Post date:** [April 26, 2026, 1:26am UTC](https://forum.makecode.com/t/picking-random-sprite-out-of-a-group-of-the-same-sprites/43637/1 "2026-04-26T01:26:34Z")

</div>

Trying to move sprite1 to a random sprite2 but there is more than one sprite2s.

---

<div class="post-metadata">

**Author:** ![YamJam](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yamjam/32/29681_2.png) [@YamJam](https://forum.makecode.com/u/YamJam)\
**Post date:** [April 26, 2026, 6:04pm UTC](https://forum.makecode.com/t/picking-random-sprite-out-of-a-group-of-the-same-sprites/43637/2 "2026-04-26T18:04:45Z")

</div>

You can use arrays. Just set the posistion to the position of a random sprite in an array of sprite2 types.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/b/a/ba5cd15496fa2d6d8609a378be9be85b37df8058.png)

---

<div class="post-metadata">

**Author:** ![OrigamiArtist](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/origamiartist/32/33299_2.png) [@OrigamiArtist](https://forum.makecode.com/u/OrigamiArtist)\
**Post date:** [April 26, 2026, 6:24pm UTC](https://forum.makecode.com/t/picking-random-sprite-out-of-a-group-of-the-same-sprites/43637/3 "2026-04-26T18:24:10Z")

</div>

@plierplierplier you might want to use an array:

1. Go to Advanced
2. Select Arrays.
3. Create a number array
4. Go to Images and take out an image (|\_|) block.
5. Drag it into the array. Repeat for each array selection.
6. Put it into `On Start`
7. Put a `On game update every __ ms then` and drag a set mySprite image to Get random value from myArray. Here is an example  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/1/0/10b9dd87d7a2b0847bc20fbde3d316b40441671c.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/4/6/46e7cf657947fa55d5993b2ac6f880f3a4251197.png)

---

<div class="post-metadata">

**Author:** ![redSprite](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/redsprite/32/34262_2.png) [@redSprite](https://forum.makecode.com/u/redSprite)\
**Post date:** [April 26, 2026, 6:41pm UTC](https://forum.makecode.com/t/picking-random-sprite-out-of-a-group-of-the-same-sprites/43637/4 "2026-04-26T18:41:12Z")

</div>

Assemble the “sprite2” sprites into one big list, then you can use the “get random value from” to pick a random sprite2 from that array, get their x and y, and set sprite1 x and y to random sprite2’s x and y.
