# A very specific problem (how to hide show stats button, problem with rand function)

**URL:** <https://forum.choiceofgames.com/t/a-very-specific-problem-how-to-hide-show-stats-button-problem-with-rand-function/12094>\
**Category:** ChoiceScript Help\
**Created:** [September 28, 2015, 10:58am UTC](https://forum.choiceofgames.com/t/a-very-specific-problem-how-to-hide-show-stats-button-problem-with-rand-function/12094 "2015-09-28T10:58:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sergey\_Konyakin](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@Sergey\_Konyakin](https://forum.choiceofgames.com/u/Sergey_Konyakin)\
**Post date:** [September 28, 2015, 10:58am UTC](https://forum.choiceofgames.com/t/a-very-specific-problem-how-to-hide-show-stats-button-problem-with-rand-function/12094/1 "2015-09-28T10:58:04Z")

</div>

As always - sry for bad english )))

Hi, all, me and my friend almost finished our first game. Unfortunately, I found one annoying bug.

We used rand function in our game (simulation of 2 dice with 6 edges, like in classical board games) for create a stat-checks in game. Throws two “dice”, they added buffs and the resulting number is compared with the number of checks. But in the page after this every time when player go to show stats, and after this go back to main game, this dice roll again and all a changes!!!

Here a bit of code for example:

 ![](https://global.discourse-cdn.com/choiceofgames/original/2X/b/b8fc8b69c02aa1a14bdee4acf6a50b1dd35ee4a8.png)

Player go to “show stat” and after this he back in game and all “dice” reroll again!!! I have one question - how to fix it? )))

1. Maybe I can just hide “show stats” stats in some scenes - but how???

2. Or maybe I can somehow make my rand function non-reusable in some scenes - but again, how???

---

<div class="post-metadata">

**Author:** ![Cecilia\_Rosewood](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cecilia_rosewood/32/253835_2.png) [@Cecilia\_Rosewood](https://forum.choiceofgames.com/u/Cecilia_Rosewood)\
**Post date:** [September 28, 2015, 11:19am UTC](https://forum.choiceofgames.com/t/a-very-specific-problem-how-to-hide-show-stats-button-problem-with-rand-function/12094/2 "2015-09-28T11:19:21Z")

</div>

The easy way would be to do the dice roll in the scene before the choice. That way it won’t reset if you go to the stats screen after making a choice.

If you’re looking for a solution more complicated than that you’ll have to ask the coding wizards. I only know the basics.

---

<div class="post-metadata">

**Author:** ![Sergey\_Konyakin](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@Sergey\_Konyakin](https://forum.choiceofgames.com/u/Sergey_Konyakin)\
**Post date:** [September 28, 2015, 11:20am UTC](https://forum.choiceofgames.com/t/a-very-specific-problem-how-to-hide-show-stats-button-problem-with-rand-function/12094/3 "2015-09-28T11:20:47Z")

</div>

Hm, very interesting - I will try it, tnx! )

---

<div class="post-metadata">

**Author:** ![Sergey\_Konyakin](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@Sergey\_Konyakin](https://forum.choiceofgames.com/u/Sergey_Konyakin)\
**Post date:** [September 28, 2015, 11:29am UTC](https://forum.choiceofgames.com/t/a-very-specific-problem-how-to-hide-show-stats-button-problem-with-rand-function/12094/4 "2015-09-28T11:29:14Z")

</div>

Amazing!!! It really works!!! But I will wait for another answers - maybe someone know something about how to hide show stats button ))) Tnx!

---

<div class="post-metadata">

**Author:** ![ysalmari](https://avatars.discourse-cdn.com/v4/letter/y/c57346/32.png) [@ysalmari](https://forum.choiceofgames.com/u/ysalmari)\
**Post date:** [September 29, 2015, 5:18am UTC](https://forum.choiceofgames.com/t/a-very-specific-problem-how-to-hide-show-stats-button-problem-with-rand-function/12094/5 "2015-09-29T05:18:24Z")

</div>

The best way to hide stats that I’ve figured out is to create a variable and set it to false when you want the stats to be hidden. Then you can set up the stat screen to only show those stats when the variable is true. It doesn’t erase the “show stat button”, but it can hide some stats while letting you show others.

---

<div class="post-metadata">

**Author:** ![Chwoka](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/chwoka/32/3737_2.png) [@Chwoka](https://forum.choiceofgames.com/u/Chwoka)\
**Post date:** [October 1, 2015, 6:07pm UTC](https://forum.choiceofgames.com/t/a-very-specific-problem-how-to-hide-show-stats-button-problem-with-rand-function/12094/6 "2015-10-01T18:07:11Z")

</div>

His problem isn’t so much that he doesn’t want the players to be able to see their stats, it’s that every time they go to their stats page and back the \*rand function rerolls because the page you’re on isn’t stored, it’s just reloaded, and the page rereads and reapplies all the code in it all over again. I’ve had the same problem even without a \*rand, with a stray “oh I’ll add a +20 here,” and then every time you would go to your stats page and back it would increase by 20!

The simple solution is to roll it well in advance. If that’s not possible though, you’d have to use a \*goto or \*page\_break or

---

<div class="post-metadata">

**Author:** ![Doppelgangland](https://avatars.discourse-cdn.com/v4/letter/d/dbc845/32.png) [@Doppelgangland](https://forum.choiceofgames.com/u/Doppelgangland)\
**Post date:** [May 25, 2016, 2:15pm UTC](https://forum.choiceofgames.com/t/a-very-specific-problem-how-to-hide-show-stats-button-problem-with-rand-function/12094/7 "2016-05-25T14:15:40Z")

</div>

You can use a conditional in the stats page, so that different parts show when different conditions are met.
