State condition (IF with random variable)

Someone can help me with this? I want to add a random chance for this effect to happen. It's a state effect.
I tried adding "Math.random()" with IF condition, but didn't work out.

Code:
<Custom Regenerate Effect>
user._linkenCooldown = user._linkenCooldown || 0;
user._linkenCooldown = Math.ceil(user._linkenCooldown - 1, 0);
</Custom Regenerate Effect>

<Custom Select Effect>
target._linkenCooldown = target._linkenCooldown || 0;
if (target._linkenCooldown <= 0) {
  if (this.item() && DataManager.isSkill(this.item()) && this.isForOpponent()) {
    var blockedtypes = [];
    blockedtypes.push(1);
    var blockedskills = [];
    blockedskills.push(1, 3);
    if (blockedtypes.contains(this.item().stypeId) || blockedskills.contains(this.item().id)) {
      this._formerItemSuccessRate = this.item().successRate;
      this.item().successRate = 50;
      target.startAnimation(21);
      target._linkenCooldown = 2;
    }
  }
}
</Custom Select Effect>

<Custom Deselect Effect>
if (this._formerItemSuccessRate !== undefined) {
  this.item().successRate = this._formerItemSuccessRate;
}
</Custom Deselect Effect>
Moved to JavaScript/Plugin Support - this is the board to post on when you have questions about how to use a plugin correctly, including how to write good notetags.
You can do this
Code:
if (chance > Math.random()) { ... }
, whereas chance is a float 0.0 <= x <= 1.0 (0.0 never, 1.0 always)

Original thread: https://forums.rpgmakerweb.com/threads/state-condition-if-with-random-variable.132196/