# How would I make something happen only when a specific number is randomly generated?

**URL:** <https://forum.makecode.com/t/how-would-i-make-something-happen-only-when-a-specific-number-is-randomly-generated/28142>\
**Category:** Arcade\
**Created:** [April 8, 2024, 8:17pm UTC](https://forum.makecode.com/t/how-would-i-make-something-happen-only-when-a-specific-number-is-randomly-generated/28142 "2024-04-08T20:17:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lilvince](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@Lilvince](https://forum.makecode.com/u/Lilvince)\
**Post date:** [April 8, 2024, 8:17pm UTC](https://forum.makecode.com/t/how-would-i-make-something-happen-only-when-a-specific-number-is-randomly-generated/28142/1 "2024-04-08T20:17:17Z")

</div>

How would I make for example a character move every time a specific number is chosen? For example 1 - 20, number needed is 5

---

<div class="post-metadata">

**Author:** ![robotosaurus](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/robotosaurus/32/19294_2.png) [@robotosaurus](https://forum.makecode.com/u/robotosaurus)\
**Post date:** [April 9, 2024, 2:12pm UTC](https://forum.makecode.com/t/how-would-i-make-something-happen-only-when-a-specific-number-is-randomly-generated/28142/2 "2024-04-09T14:12:40Z")

</div>

Here’s the code.

> **[rnd move sprite](https://arcade.makecode.com/S75355-58756-30210-36079)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![Josef](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/josef/32/12457_2.png) [@Josef](https://forum.makecode.com/u/Josef)\
**Post date:** [April 9, 2024, 2:16pm UTC](https://forum.makecode.com/t/how-would-i-make-something-happen-only-when-a-specific-number-is-randomly-generated/28142/3 "2024-04-09T14:16:40Z")

</div>

![Screenshot 2024-04-09 at 4.35.56 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/a54215d3a08c33ea24372888f12bf4d17c542d2e.png)  
Here you go

---

<div class="post-metadata">

**Author:** ![Lilvince](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@Lilvince](https://forum.makecode.com/u/Lilvince)\
**Post date:** [April 10, 2024, 4:05pm UTC](https://forum.makecode.com/t/how-would-i-make-something-happen-only-when-a-specific-number-is-randomly-generated/28142/4 "2024-04-10T16:05:06Z")

</div>

Well dang, thats less complicated than the code I had or it could be more complicated since what I have is if random number 1 - 20 =/\< 5 change creature1 phase by 1 (yes this does work, sure makes it a pain though to scroll through the code but this would make it harder)

---

<div class="post-metadata">

**Author:** ![Lilvince](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@Lilvince](https://forum.makecode.com/u/Lilvince)\
**Post date:** [April 10, 2024, 4:05pm UTC](https://forum.makecode.com/t/how-would-i-make-something-happen-only-when-a-specific-number-is-randomly-generated/28142/5 "2024-04-10T16:05:11Z")

</div>

Ty, this is the method I’ve been using for awhile, I was extremely tired when I wrote this thread and didn’t think about this one
