# Randomizing values

**URL:** <https://forums.moddingtree.com/t/randomizing-values/434>\
**Category:** Modding Developers\
**Created:** [February 8, 2022, 2:43am UTC](https://forums.moddingtree.com/t/randomizing-values/434 "2022-02-08T02:43:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alezman](https://forums.moddingtree.com/user_avatar/forums.moddingtree.com/alezman/32/96_2.png) [@alezman](https://forums.moddingtree.com/u/alezman)\
**Post date:** [February 8, 2022, 2:43am UTC](https://forums.moddingtree.com/t/randomizing-values/434/1 "2022-02-08T02:43:21Z")

</div>

(this is a continuation of my last thread jsyk)  
How to make it so after two variables match, their values are randomized within a range of 1-10,  
and also they add +X to prestige points? pls answer

---

<div class="post-metadata">

**Author:** ![thepaperpilot](https://forums.moddingtree.com/user_avatar/forums.moddingtree.com/thepaperpilot/32/74_2.png) [@thepaperpilot](https://forums.moddingtree.com/u/thepaperpilot)\
**Post date:** [February 8, 2022, 12:32pm UTC](https://forums.moddingtree.com/t/randomizing-values/434/5 "2022-02-08T12:32:58Z")

</div>

Checking if two variables match:

```javascript
if (a === b) {

}

```

If they are decimals, you can do `a.eq(b)` instead

Getting a random value from 1-10:

```javascript
Math.ceil(Math.random() * 10)

```

Adding x prestige points:

```javascript
addPoints("p", X)

```

---

<div class="post-metadata">

**Author:** ![alezman](https://forums.moddingtree.com/user_avatar/forums.moddingtree.com/alezman/32/96_2.png) [@alezman](https://forums.moddingtree.com/u/alezman)\
**Post date:** [February 8, 2022, 9:50pm UTC](https://forums.moddingtree.com/t/randomizing-values/434/6 "2022-02-08T21:50:37Z")

</div>

thats epic but where do i place that? in an update diff in the bar section idk lol  
(sorry if it sounded a bit rude i do not mean to offend by any means)

---

<div class="post-metadata">

**Author:** ![thepaperpilot](https://forums.moddingtree.com/user_avatar/forums.moddingtree.com/thepaperpilot/32/74_2.png) [@thepaperpilot](https://forums.moddingtree.com/u/thepaperpilot)\
**Post date:** [February 8, 2022, 9:52pm UTC](https://forums.moddingtree.com/t/randomizing-values/434/7 "2022-02-08T21:52:11Z")

</div>

Probably in the layer’s update method? That’ll run once per tick

---

<div class="post-metadata">

**Author:** ![alezman](https://forums.moddingtree.com/user_avatar/forums.moddingtree.com/alezman/32/96_2.png) [@alezman](https://forums.moddingtree.com/u/alezman)\
**Post date:** [February 8, 2022, 9:56pm UTC](https://forums.moddingtree.com/t/randomizing-values/434/8 "2022-02-08T21:56:05Z")

</div>

also sorry to bother once again but the bar stays full without moving, is there any way to fix this?

```auto
bars: {
    bigBar: {
        direction: RIGHT,
        width: 600,
        height: 50,
        progress() {
           return player.p.currently.div(player.p.goal).clamp(0, 1);
        }
    },
  },

```

If I’m doing something wrong and it’s very obvious please let me know

---

<div class="post-metadata">

**Author:** ![thepaperpilot](https://forums.moddingtree.com/user_avatar/forums.moddingtree.com/thepaperpilot/32/74_2.png) [@thepaperpilot](https://forums.moddingtree.com/u/thepaperpilot)\
**Post date:** [February 8, 2022, 9:58pm UTC](https://forums.moddingtree.com/t/randomizing-values/434/9 "2022-02-08T21:58:58Z")

</div>

player.p.currently is probably greater than player.p.goal. I hadn’t realized that bit of what you were asking for in my original response, hence the follow-up with [updated code](https://forums.moddingtree.com/t/how-can-i-make-a-bar-that-shows-the-distance-between-one-variable-and-another/433/4). I’d suggest using that instead.

---

<div class="post-metadata">

**Author:** ![thepaperpilot](https://forums.moddingtree.com/user_avatar/forums.moddingtree.com/thepaperpilot/32/74_2.png) [@thepaperpilot](https://forums.moddingtree.com/u/thepaperpilot)\
**Post date:** [February 9, 2022, 3:59am UTC](https://forums.moddingtree.com/t/randomizing-values/434/10 "2022-02-09T03:59:53Z")

</div>

BTW, you can select a post as an accepted solution, and it’ll appear directly underneath the original post, making it easier for people with the same problem as you to find the answer.
