Spot that heals by percentages

I've been looking a tutorials and the closest I found was a "for" loop that heals by a set number

var x = $gameParty.members().length;

for (i = 0; i < x; ++i) {

$gameParty.members().gainHp(10);

}

I want to know how to change it so it heals by 5% of max hp instead of just 10 hp
Just need to multiply max HP by the percentage to get the heal amount. Try something like:
Code:
for (var n = 0; n < $gameParty.members().length; n++) {
  var actor = $gameParty.members()[n];
  var heal = Math.floor(0.05 * actor.mhp);
  actor.gainHp(heal);
}
Or, with a forEach instead:
Code:
$gameParty.members().forEach(function(member) {
  var heal = Math.floor(0.05 * member.mhp);
  member.gainHp(heal);
});
I tried this using only a single member in the party, but it healed the character by 93% instead. I'm also a beginner in coding, but I understand about everything you showed me in the first code except Math.floor and I don't know anything about forEach functions.
Caerthyril is spot on. Both his codes will work. If it heals for 93% something's wrong. 0.05 * actor.mhp is 5% of maximum hp.
I discovered the in game problem: the script isn't using an individual actor's max Hp. When I put more than one party member their health all restores by the same constant. So the percentage was right, but it's using 8,360 instead of the actor's Max Hp,
Could you post your code?
Sauna heal help.PNG
The code is supposed to work, I just tested it. Perhaps it's healing more than 5% because it's being called more than once. How do you call that common event?
You're right, I have a bunch of them placed down that are activated by a switch. It must be all them activating at once

Original thread: https://forums.rpgmakerweb.com/threads/spot-that-heals-by-percentages.106927/