A Skill That Fails If Not Above A Certain Number?

Hi, so I wanted to get a little experimental when it comes to making skills and DND is one of the first things that came to mind.
What I'm looking for is help creating a skill that has a random variable, and if it's not equal to or above that number it fails and if it is, the skill is used.
Sorry if it's an easy ask, but my coding knowledge is horrendous.
Any help please?

(Also I'm using Yanfly Plugins if it helps)

Edit : The variable would be 1-20. Also I know the base game has a built a built in chance of success/fail system, but I wanted to place a dice roll animation on the skill activation, and the number it rolled on.
depends on what the skill does.

if its damage, then you could have something like
Code:
Math.randomInt(20)+1 > 12 ? (damage formula):0

if it applies a state or some other effect then you can do something like
Code:
<After Eval>
if (Math.randomInt(20) + 1 > 18)
  target.addState(x);
</After Eval>

if its a skill that if you specifically need to call another skill, then it could look soemthing like
Code:
<After Eval>
if (Math.randomInt(20) + 1 > 7)
  BattleManager.queueForceAction(user, x, target);
</After Eval>

EDIT: didnt see the edit. if you have animations for all the results, then you can add a call for the dice roll animations as well.
Code:
<After Eval>
var roll = Math.randomInt(20) + 1;
if (roll > 10){
  //assuming your roll animation id's start at 21
  user.startAnimation(20 + roll);
  BattleManager.queueForceAction(user, x, target);
}
</After Eval>
depends on what the skill does.

if its damage, then you could have something like
Code:
Math.randomInt(20)+1 > 12 ? (damage formula):0

if it applies a state or some other effect then you can do something like
Code:
<After Eval>
if (Math.randomInt(20) + 1 > 18)
  target.addState(x);
</After Eval>

if its a skill that if you specifically need to call another skill, then it could look soemthing like
Code:
<After Eval>
if (Math.randomInt(20) + 1 > 7)
  BattleManager.queueForceAction(user, x, target);
</After Eval>
Thanks, this is exactly what I was looking for. Just wanted to know how the

Code:
if (Math.randomInt(20) + 1 > 7)

Worked. I get the the first part, but kinda confused how the "+1 > 7)" works.
Worked. I get the the first part, but kinda confused how the "+1 > 7)" works.
math.randomInt(x) rolls a random whole number that can be anything starting from 0 and ending at x-1.
So, if you want to sim a d20, you can say "math.randomInt(20)+1". you get a range of possible numbers from 1-20. (0-19, plus 1)

then, the >7 is to check if the d20 roll was greater than 7, and if it was, do the thing
math.randomInt(x) rolls a random whole number that can be anything starting from 0 and ending at x-1.
So, if you want to sim a d20, you can say "math.randomInt(20)+1". you get a range of possible numbers from 1-20. (0-19, plus 1)

then, the >7 is to check if the d20 roll was greater than 7, and if it was, do the thing
Ah ok I got it. Thanks

Original thread: https://forums.rpgmakerweb.com/threads/a-skill-that-fails-if-not-above-a-certain-number.166037/