Dice procedure help

how to make it so that I can get a dice and immediately return a random value to the program, it is not sent select before if. if the check is transferred to a procedure, then the meaning in it disappears, I will need to call it hundreds of times. How to make it so that when you need to press a button, the user receives a random number, and after that the necessary buttons appear further? I'm making an old-style game, a text-based one, when the 1990s were in vogue. Nostalgia. Maybe in vain he started doing this at MIT? I just thought it would be faster and easier. Although Junior himself.