MZ Parameters Aren't Working

I made a plugin to change how my attacks work and to mimic how final fantasy games have multiple hits per attack. The plugin works as intended, but I just realized my parameters aren't working. They get set to the default and no matter what I change in the plugin menu it still uses the default. Does anyone know what I messed up here?

Code:
/////////////////////////////////////////////////////////////////
// RFG-Multiple Hits System v0.2
// Author: RedFoxGaming
/////////////////////////////////////////////////////////////////
/*:
 * @plugindesc A Multiple Hits attack system similar to Final Fantasy
 * @author RedFoxGaming
 *
 * This plugin has no plugin commands
 *
 * @param Maximum Possible Hits
 * @desc The maximum possible amount of hits, without state modifiers
 * @default 16
 *
 * @param Maximum Magic Hits
 * @desc The maximum possible magic multipliers
 * @default 6
 *
 * @param Double Hits State
 * @desc The stateID of the state you want to double your hits (will go beyond max)
 * @default 10
 *
 * @param Half Hits State
 * @desc The stateID of the state you want to half your hits
 * @default 11
 *
 * @param Possible Hits Formula
 * @type text
 * @desc The formula that calculates how many hits are possible
 * @default a.agi / 16
 *
 * @param Possible Magic Hits Formula
 * @type text
 * @desc The formula that calculates how many magic hits are possible
 * @default a.mat / 32
 *
 * @param Damage Formula
 * @type text
 * @desc The default damage formula
 * @default a.atk * 4 - b.def * 2
 *
 * @param Magic Damage Formula
 * @desc The default damage formula for spells (Base argument is used for a number base damage)
 * @default base + a.mat * 2 - b.mdf * 2
 *
 * @param Healing Magic Formula
 * @desc The default formula for healing magics
 * @default base + a.mdf
 *
 * @param Actual Hits Variable
 * @desc The ingame variable to store your hits scored (to use in messages)
 * @default 1
 *
 * @param Maximum Damage
 * @desc The max damage the character can do at any time
 * @default 9999
 *
 * @help
 *
 * ----------------------------------------------
 * RFG Multiple Hits System
 * Version 0.2
 * ----------------------------------------------
 *
 * The purpose of this plugin is to mimic the way Final Fantasy handles their
 * attacking system, where your attack has the possibility of landing multiple
 * hits. In order to use this plugin, all you have to do is replace your formulas
 * in the skills you have set to attack, or your magic formulas to my functions.
 *
 * Function for Physical Attacks
 * this.physicalAttack(a,b);
 *
 * Function for Magical Attacks
 * this.magicalAttack(a,b,base); where base is a default number value
 * Note: You must use base in the formula if you want a base number value for your spells, otherwise;
 * use this.magicalAttack(a,b,0);
 *
 * Function for Healing Magic
 * this.healingMagic(a,b,base); where base is a default number value
*/
    function getRandomInt (min,max) { //Define a function to get a random range of numbers
        min = Math.ceil(min);
        max = Math.floor(max) + 1;
        return Math.floor(Math.random() * (max - min)) + min;
    }
    function toNumber(str, def) { //Define a function to assign parameters to a number value
        return isNaN(str) ? def : +(str || def);
    }
    var parameters = PluginManager.parameters("RFG-MultipleHitsSystem"); //Load all parameters into an array
    var mhitsposs = toNumber(parameters['Maximum Possible Hits'], 16); //Set variable for Max Possible Hits
    var mmagicposs = toNumber(parameters['Maximum Magic Hits'], 6); //Set a variable for Max Magic Multiplier
    var doublehitsstate = toNumber(parameters['Double Hits State'], 10); //Set a variable for a state that doubles hits
    var halfhitsstate = toNumber(parameters['Half Hits State'], 11); //Set a variable for a state that halves hits
    var phitsform = parameters['Possible Hits Formula'] || "a.agi / 16"; //Set a variable for a formula that defines possible hits
    var mhitsform = parameters['Possible Magic Hits Formula'] || "m.mat / 32"; //Set a variable to define same thing for magic hits
    var damageform = parameters['Damage Formula'] || "a.atk * 4 - b.def * 2"; //Set your default damage formula
    var magicdamform = parameters['Magic Damage Formula'] || "base + a.mat * 2 - b.mdf * 2"; //Set your default magic damage formula
    var healingmagform = parameters['Healing Magic Formula'] || "base + a.mdf"; //Set your default healing formula
    var actualhitsvar = toNumber(parameters['Actual Hits Variable'], 1); //Set the ingame variable to track hits landed
    var maxdamage = toNumber(parameters['Maximum Damage'], 9999);
    var phits = 0; //Init phits variable
    var damage = 0; //Init damage variable
    Game_Action.prototype.physicalAttack = function(a,b){ //Physical attack function
        damage = 0; //Set damage to 0
        $gameVariables.setValue(actualhitsvar, 0); //Set hits landed to 0
        phits = Math.floor(eval(phitsform)); //Evaluate phits formula
        if(phits < 1) { phits = 1; } //If less than 1, make it 1
        if(phits > mhitsposs) { phits = mhitsposs; } //If higher than the max possible hits, set to max possible hits
        //if(a.isStateAffected(doublehitsstate)) { phits = phits * 2; } //If double state inflicted, double hits
        //if(a.isStateAffected(halfhitsstate)) { phits = phits / 2; } //If half state inflicted, half hits
        for(i=0; i < phits; i++){ //Main damage calculation for loop
            if(getRandomInt(0, 100) > 100 - (a.hit * 100) && getRandomInt(0, 100) > (b.eva * 100)) { //If both of these conditions are true, than this was a successful hit
                damage = damage + eval(damageform); //Add damage to damage pool
                $gameVariables.setValue(actualhitsvar, $gameVariables.value(actualhitsvar) + 1); //Add one to actual hits if sucessful
            }
            if($gameVariables.value(actualhitsvar) < 1){ //If there were 0 sucessful hits, set to 1. Let game engine handle misses and evasions
                $gameVariables.setValue(actualhitsvar, 1);
                damage = eval(damageform); //Do damage, even if the plugin scored 0 hits
            }
        }
        if(damage > maxdamage) { damage = maxdamage; }
        return damage;
    }
    Game_Action.prototype.magicalAttack = function(a,b,base){
        damage = 0;
        $gameVariables.setValue(actualhitsvar, 0);
        var phits = Math.floor(eval(mhitsform));
        if(phits < 1) { phits = 1; }
        if(phits > mmagicposs) { phits = mmagicposs; }
        for(i=0; i < phits; i++){
            if(getRandomInt(0, 100) > 100 - (a.hit * 100) && getRandomInt(0, 100) > (b.eva * 100)){
                damage = damage + eval(magicdamform);
                $gameVariables.setValue(actualhitsvar, $gameVariables.value(actualhitsvar) + 1);
            }
            if($gameVariables.value(actualhitsvar) < 1){
                $gameVariables.setValue(actualhitsvar, 1);
                damage = eval(magicdamform);
            }
        }
        if(damage > maxdamage) { damage = maxdamage; }
        return damage;
    }
    Game_Action.prototype.healingMagic = function(a,b,base){
        damage = 0;
        $gameVariables.setValue(actualhitsvar, 0);
        var phits = Math.floor(eval(mhitsform));
        if(phits < 1) { phits = 1; }
        if(phits > mmagicposs) { phits = mmagicposs; }
        for(i=0; i < phits; i++){
            if(getRandomInt(0, 100) > 100 - (a.hit * 100) && getRandomInt(0, 100) > (b.eva * 100)){
                damage = damage + eval(healingmagform);
                $gameVariables.setValue(actualhitsvar, $gameVariables.value(actualhitsvar) + 1);
            }
            if($gameVariables.value(actualhitsvar) < 1){
                $gameVariables.setValue(actualhitsvar, 1);
                damage = eval(healingmagform);
            }
        }
        if(damage > maxdamage) { damage = maxdamage; }
        return damage;
    }
    Game_Action.prototype.rangedMagicAttack = function(a,b,min,max){
    }
    Game_Action.prototype.setHitsPhysicalAttack = function(a,b,hits,guarenteed){
      //This function is used if you want an attack to use a set number of hits
      //Like guarenteed dual attacks or an octopus 8 tenticle attack
      damage = 0;
      $gameVariables.setValue(actualhitsvar, 0);
      if(guarenteed != true){
        for(i=0; i < hits; i++){
            if(getRandomInt(0, 100) > 100 - (a.hit * 100) && getRandomInt(0, 100) > (b.eva * 100)){
                damage = damage + eval(damageform);
                $gameVariables.setValue(actualhitsvar, $gameVariables.value(actualhitsvar) + 1);
            }
            if($gameVariables.value(actualhitsvar) < 1){
                $gameVariables.setValue(actualhitsvar, 1);
                damage = eval(damageform);
            }
        }
      }
      else if(guarenteed == true){
        for(i=0; i < hits; i++){
          damage = damage + eval(damageform);
          $gameVariables.setValue(actualhitsvar, hits);
        }
      }
      if(damage > maxdamage) { damage = maxdamage; }
      return damage;
    }
Some points:
  1. Make sure you've saved your project to apply Plugin Manager changes before testing!

  2. Plugin parameters are stored under the plugin's file name. You are fetching the parameters like this:

    var parameters = PluginManager.parameters("RFG-MultipleHitsSystem");
    ...so the plugin file should be named RFG-MultipleHitsSystem.js.

  3. var scopes to its function block, which in this case is window, the global object. This means the functions and var statements at the start are all in the global scope. This means they might get overwritten by a script call or another plugin.
    Spoiler: Click to see plugin structure suggestions
    • Put everything inside a function to ensure it's locally-scoped, e.g. an IIFE:
      JavaScript:
      (function() {  // local function scope
        let parameters = PluginManager.parameters('RFG-MultipleHitsSystem');
        // etc
      })();
    • Define one global variable, and have everything else as a property of that, e.g.
      JavaScript:
      window.RFG ||= {};              // author namespace (global)
      RFG.MultipleHitsSystem ||= {};  // plugin namespace
      RFG.MultipleHitsSystem.parameters = PluginManager.parameters('RFG-MultipleHitsSystem');
      // etc
    • Both of the above (my personal preference), e.g.
      JavaScript:
      window.RFG ||= {};  // author namespace
      (function($) {  // in here, $ = RFG.MultipleHitsSystem
        $.parameters = PluginManager.parameters('RFG-MultipleHitsSystem');
        // etc
      })(RFG.MultipleHitsSystem ||= {});

    Links for further reading~

  4. You can use @type directives for some of your other parameters, e.g.
    • @type state for the Double/Half Hits state ID params
    • @type number for the Maximum Hits and Maximum Damage params
    • @type variable for the Actual Hits Variable param
    This is just for presentation: users can still input any value via the Text tab in the Plugin Manager.

  5. You can suppress the Plugin Manager's compatibility warning by adding a @target MZ line to the plugin header (e.g. just above @plugindesc).
So I tried setting the script up that way, and I get an error saying parameters is not defined. Also, even after saving the project, if I change any parameters in the plugin menu, they still don't carry over. It still uses the defaults. Here is the update code following your advice.
Code:
window.RFG ||= {};
(function($){
    function getRandomInt (min,max) { //Define a function to get a random range of numbers
        min = Math.ceil(min);
        max = Math.floor(max) + 1;
        return Math.floor(Math.random() * (max - min)) + min;
    }
    function toNumber(str, def) { //Define a function to assign parameters to a number value
        return isNaN(str) ? def : +(str || def);
    }
    $.parameters = PluginManager.parameters("RFG-MultipleHitsSystem"); //Load all parameters into an array
    $.mhitsposs = toNumber(parameters['Maximum Possible Hits'], 16); //Set variable for Max Possible Hits
    $.mmagicposs = toNumber(parameters['Maximum Magic Hits'], 6); //Set a variable for Max Magic Multiplier
    $.doublehitsstate = toNumber(parameters['Double Hits State'], 10); //Set a variable for a state that doubles hits
    $.halfhitsstate = toNumber(parameters['Half Hits State'], 11); //Set a variable for a state that halves hits
    $.phitsform = parameters['Possible Hits Formula'] || "a.agi / 16"; //Set a variable for a formula that defines possible hits
    $.mhitsform = parameters['Possible Magic Hits Formula'] || "m.mat / 32"; //Set a variable to define same thing for magic hits
    $.damageform = parameters['Damage Formula'] || "a.atk * 4 - b.def * 2"; //Set your default damage formula
    $.magicdamform = parameters['Magic Damage Formula'] || "base + a.mat * 2 - b.mdf * 2"; //Set your default magic damage formula
    $.healingmagform = parameters['Healing Magic Formula'] || "base + a.mdf"; //Set your default healing formula
    $.actualhitsvar = toNumber(parameters['Actual Hits Variable'], 1); //Set the ingame variable to track hits landed
    $.maxdamage = toNumber(parameters['Maximum Damage'], 9999);
    $.phits = 0; //Init phits variable
    $.damage = 0; //Init damage variable
    Game_Action.prototype.physicalAttack = function(a,b){ //Physical attack function
        damage = 0; //Set damage to 0
        $gameVariables.setValue(actualhitsvar, 0); //Set hits landed to 0
        phits = Math.floor(eval(phitsform)); //Evaluate phits formula
        if(phits < 1) { phits = 1; } //If less than 1, make it 1
        if(phits > mhitsposs) { phits = mhitsposs; } //If higher than the max possible hits, set to max possible hits
        if(a.isStateAffected(doublehitsstate)) { phits = phits * 2; } //If double state inflicted, double hits
        if(a.isStateAffected(halfhitsstate)) { phits = phits / 2; } //If half state inflicted, half hits
        for(i=0; i < phits; i++){ //Main damage calculation for loop
            if(getRandomInt(0, 100) > 100 - (a.hit * 100) && getRandomInt(0, 100) > (b.eva * 100)) { //If both of these conditions are true, than this was a successful hit
                damage = damage + eval(damageform); //Add damage to damage pool
                $gameVariables.setValue(actualhitsvar, $gameVariables.value(actualhitsvar) + 1); //Add one to actual hits if sucessful
            }
            if($gameVariables.value(actualhitsvar) < 1){ //If there were 0 sucessful hits, set to 1. Let game engine handle misses and evasions
                $gameVariables.setValue(actualhitsvar, 1);
                damage = eval(damageform); //Do damage, even if the plugin scored 0 hits
            }
        }
        if(damage > maxdamage) { damage = maxdamage; }
        return damage;
    }
    Game_Action.prototype.magicalAttack = function(a,b,base){
        damage = 0;
        $gameVariables.setValue(actualhitsvar, 0);
        phits = Math.floor(eval(mhitsform));
        if(phits < 1) { phits = 1; }
        if(phits > mmagicposs) { phits = mmagicposs; }
        for(i=0; i < phits; i++){
            if(getRandomInt(0, 100) > 100 - (a.hit * 100) && getRandomInt(0, 100) > (b.eva * 100)){
                damage = damage + eval(magicdamform);
                $gameVariables.setValue(actualhitsvar, $gameVariables.value(actualhitsvar) + 1);
            }
            if($gameVariables.value(actualhitsvar) < 1){
                $gameVariables.setValue(actualhitsvar, 1);
                damage = eval(magicdamform);
            }
        }
        if(damage > maxdamage) { damage = maxdamage; }
        return damage;
    }
    Game_Action.prototype.healingMagic = function(a,b,base){
        damage = 0;
        $gameVariables.setValue(actualhitsvar, 0);
        phits = Math.floor(eval(mhitsform));
        if(phits < 1) { phits = 1; }
        if(phits > mmagicposs) { phits = mmagicposs; }
        for(i=0; i < phits; i++){
            if(getRandomInt(0, 100) > 100 - (a.hit * 100) && getRandomInt(0, 100) > (b.eva * 100)){
                damage = damage + eval(healingmagform);
                $gameVariables.setValue(actualhitsvar, $gameVariables.value(actualhitsvar) + 1);
            }
            if($gameVariables.value(actualhitsvar) < 1){
                $gameVariables.setValue(actualhitsvar, 1);
                damage = eval(healingmagform);
            }
        }
        if(damage > maxdamage) { damage = maxdamage; }
        return damage;
    }
    Game_Action.prototype.rangedMagicAttack = function(a,b,min,max){
    }
    Game_Action.prototype.setHitsPhysicalAttack = function(a,b,hits,guarenteed){
      //This function is used if you want an attack to use a set number of hits
      //Like guarenteed dual attacks or an octopus 8 tenticle attack
      damage = 0;
      $gameVariables.setValue(actualhitsvar, 0);
      if(guarenteed != true){
        for(i=0; i < hits; i++){
            if(getRandomInt(0, 100) > 100 - (a.hit * 100) && getRandomInt(0, 100) > (b.eva * 100)){
                damage = damage + eval(damageform);
                $gameVariables.setValue(actualhitsvar, $gameVariables.value(actualhitsvar) + 1);
            }
            if($gameVariables.value(actualhitsvar) < 1){
                $gameVariables.setValue(actualhitsvar, 1);
                damage = eval(damageform);
            }
        }
      }
      else if(guarenteed == true){
        for(i=0; i < hits; i++){
          damage = damage + eval(damageform);
          $gameVariables.setValue(actualhitsvar, hits);
        }
      }
      if(damage > maxdamage) { damage = maxdamage; }
      return damage;
    }
})(RFG.MultipleHitsSystem ||= {});

EDIT: Wait I'm an idiot. It is working after I saved the project. I thought it wasn't because I have my actualhitsvar set to 99 in the plugin parameters and \v[99] being used in the messages, and it still showed 0. It couldn't modify that variable because I still had my max variables at 20. I still get an undefined error if I try using the code like the above though.
Yes, parameters isn't defined because it's $.parameters now. You'll need to update all references to the original variables.

I did a search & replace on your code and came up with this, I haven't tested it though:
Spoiler: Updated plugin code
JavaScript:
window.RFG ||= {};
(function($){
    function getRandomInt (min,max) { //Define a function to get a random range of numbers
        min = Math.ceil(min);
        max = Math.floor(max) + 1;
        return Math.floor(Math.random() * (max - min)) + min;
    }
    function toNumber(str, def) { //Define a function to assign parameters to a number value
        return isNaN(str) ? def : +(str || def);
    }
    $.parameters = PluginManager.parameters("RFG-MultipleHitsSystem"); //Load all parameters into an array
    $.mhitsposs = toNumber($.parameters['Maximum Possible Hits'], 16); //Set variable for Max Possible Hits
    $.mmagicposs = toNumber($.parameters['Maximum Magic Hits'], 6); //Set a variable for Max Magic Multiplier
    $.doublehitsstate = toNumber($.parameters['Double Hits State'], 10); //Set a variable for a state that doubles hits
    $.halfhitsstate = toNumber($.parameters['Half Hits State'], 11); //Set a variable for a state that halves hits
    $.phitsform = $.parameters['Possible Hits Formula'] || "a.agi / 16"; //Set a variable for a formula that defines possible hits
    $.mhitsform = $.parameters['Possible Magic Hits Formula'] || "m.mat / 32"; //Set a variable to define same thing for magic hits
    $.damageform = $.parameters['Damage Formula'] || "a.atk * 4 - b.def * 2"; //Set your default damage formula
    $.magicdamform = $.parameters['Magic Damage Formula'] || "base + a.mat * 2 - b.mdf * 2"; //Set your default magic damage formula
    $.healingmagform = $.parameters['Healing Magic Formula'] || "base + a.mdf"; //Set your default healing formula
    $.actualhitsvar = toNumber($.parameters['Actual Hits Variable'], 1); //Set the ingame variable to track hits landed
    $.maxdamage = toNumber($.parameters['Maximum Damage'], 9999);
    $.phits = 0; //Init phits variable
    $.damage = 0; //Init damage variable
    Game_Action.prototype.physicalAttack = function(a,b){ //Physical attack function
        $.damage = 0; //Set damage to 0
        $gameVariables.setValue($.actualhitsvar, 0); //Set hits landed to 0
        $.phits = Math.floor(eval($.phitsform)); //Evaluate phits formula
        if($.phits < 1) { $.phits = 1; } //If less than 1, make it 1
        if($.phits > $.mhitsposs) { $.phits = $.mhitsposs; } //If higher than the max possible hits, set to max possible hits
        if(a.isStateAffected($.doublehitsstate)) { $.phits = $.phits * 2; } //If double state inflicted, double hits
        if(a.isStateAffected($.halfhitsstate)) { $.phits = $.phits / 2; } //If half state inflicted, half hits
        for(i=0; i < $.phits; i++){ //Main damage calculation for loop
            if(getRandomInt(0, 100) > 100 - (a.hit * 100) && getRandomInt(0, 100) > (b.eva * 100)) { //If both of these conditions are true, than this was a successful hit
                $.damage = $.damage + eval($.damageform); //Add damage to damage pool
                $gameVariables.setValue($.actualhitsvar, $gameVariables.value($.actualhitsvar) + 1); //Add one to actual hits if sucessful
            }
            if($gameVariables.value($.actualhitsvar) < 1){ //If there were 0 sucessful hits, set to 1. Let game engine handle misses and evasions
                $gameVariables.setValue($.actualhitsvar, 1);
                $.damage = eval($.damageform); //Do damage, even if the plugin scored 0 hits
            }
        }
        if($.damage > $.maxdamage) { $.damage = $.maxdamage; }
        return $.damage;
    }
    Game_Action.prototype.magicalAttack = function(a,b,base){
        $.damage = 0;
        $gameVariables.setValue($.actualhitsvar, 0);
        $.phits = Math.floor(eval($.mhitsform));
        if($.phits < 1) { $.phits = 1; }
        if($.phits > $.mmagicposs) { $.phits = $.mmagicposs; }
        for(i=0; i < $.phits; i++){
            if(getRandomInt(0, 100) > 100 - (a.hit * 100) && getRandomInt(0, 100) > (b.eva * 100)){
                $.damage = $.damage + eval($.magicdamform);
                $gameVariables.setValue($.actualhitsvar, $gameVariables.value($.actualhitsvar) + 1);
            }
            if($gameVariables.value($.actualhitsvar) < 1){
                $gameVariables.setValue($.actualhitsvar, 1);
                $.damage = eval($.magicdamform);
            }
        }
        if($.damage > $.maxdamage) { $.damage = $.maxdamage; }
        return $.damage;
    }
    Game_Action.prototype.healingMagic = function(a,b,base){
        $.damage = 0;
        $gameVariables.setValue($.actualhitsvar, 0);
        $.phits = Math.floor(eval($.mhitsform));
        if($.phits < 1) { $.phits = 1; }
        if($.phits > $.mmagicposs) { $.phits = $.mmagicposs; }
        for(i=0; i < $.phits; i++){
            if(getRandomInt(0, 100) > 100 - (a.hit * 100) && getRandomInt(0, 100) > (b.eva * 100)){
                $.damage = $.damage + eval($.healingmagform);
                $gameVariables.setValue($.actualhitsvar, $gameVariables.value($.actualhitsvar) + 1);
            }
            if($gameVariables.value($.actualhitsvar) < 1){
                $gameVariables.setValue($.actualhitsvar, 1);
                $.damage = eval($.healingmagform);
            }
        }
        if($.damage > $.maxdamage) { $.damage = $.maxdamage; }
        return $.damage;
    }
    Game_Action.prototype.rangedMagicAttack = function(a,b,min,max){
    }
    Game_Action.prototype.setHitsPhysicalAttack = function(a,b,hits,guarenteed){
      //This function is used if you want an attack to use a set number of hits
      //Like guarenteed dual attacks or an octopus 8 tenticle attack
      $.damage = 0;
      $gameVariables.setValue($.actualhitsvar, 0);
      if(guarenteed != true){
        for(i=0; i < hits; i++){
            if(getRandomInt(0, 100) > 100 - (a.hit * 100) && getRandomInt(0, 100) > (b.eva * 100)){
                $.damage = $.damage + eval($.damageform);
                $gameVariables.setValue($.actualhitsvar, $gameVariables.value($.actualhitsvar) + 1);
            }
            if($gameVariables.value($.actualhitsvar) < 1){
                $gameVariables.setValue($.actualhitsvar, 1);
                $.damage = eval($.damageform);
            }
        }
      }
      else if(guarenteed == true){
        for(i=0; i < hits; i++){
          $.damage = $.damage + eval($.damageform);
          $gameVariables.setValue($.actualhitsvar, hits);
        }
      }
      if($.damage > $.maxdamage) { $.damage = $.maxdamage; }
      return $.damage;
    }
})(RFG.MultipleHitsSystem ||= {});
😮‍💨

Original thread: https://forums.rpgmakerweb.com/threads/parameters-arent-working.139561/