How to roll a random number between two variables

So I want to roll a random number between two variables for encounters. I found this script on the forums but I can't seem to get it to work.

$gameVariables.value(13);

$gameVariables.value(14);

Math.random();

Math.min(13, 14) + rd * Math.abs(14 - 13);

$gameVariables.setValue(11, value);

thanks
use this:

Math.floor(Math.random() * (max - min + 1)) + min;

put in place of max and min your variables and set it as value to your variable #11
Thanks a bunch. I tried making something like that, but couldn't figure it out and the script I found seemed overly complicated for what I wanted to do.
So I had to modify it a bit to get it to work like I wanted so it would actually pull the numbers from the two variables. Thanks again.
Math.floor(Math.random() * ($gameVariables.value(14) - $gameVariables.value(13) + 1))+$gameVariables.value(13);
I'm sorry to bump this but I have the same issue as OP. When I try a script call with the script above, I receive a Reference Error (value is not defined). Feeling very stupid but could someone spell this out for me? Basically I would like to generate a basic number between variable#21 (the smaller number) and variable#12 (the bigger number). The result is supposed to be saved in a third variable (variable#22). Any ideas?

Edit: I just realized I simply had to enter it into the Script section of Control Variables. Sorry! The script above works perfectly! <3
I'm sorry to bump this but I have the same issue as OP. When I try a script call with the script above, I receive a Reference Error (value is not defined). Feeling very stupid but could someone spell this out for me? Basically I would like to generate a basic number between variable#21 (the smaller number) and variable#12 (the bigger number). The result is supposed to be saved in a third variable (variable#22). Any ideas?
The original issue was that the code was trying to use a value called "value" when no such value had been created or assigned. But to answer your question:

JavaScript:
const min = $gameVariables.value(21);
const max = $gameVariables.value(12);
$gameVariables.setValue(22, Math.randomInt(max - min) + min);

But also I didn't realise how long this necropost was. You may get a warning asking you to make a new topic for it.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-roll-a-random-number-between-two-variables.127899/