Percentage Healing Script Call

I have an event that I would like to heal 50% of each party member's max HP and MP. Here is the script call I am using:

$gameParty.members().forEach(function(m){
m.gainHp(0.5*(m.mhp));
m.gainMp(0.5*(m.mmp));
}());

Unfortunately, I am getting the following error:

"Cannot read property "gainHP" of undefined"

How can I make this call work as intended
hmmm, when you make a new skill you can't check both HP and MP recovery effect. But you can go in param and add a hp or mp buff, maybe it can help in the meanwhile?
If you use Yanfly's Action Sequences, you can put the following in the note field of the skill.

HP +50%: target, (show)
MP +50%: target, (show)

Be mindful that you may need to create the rest of the action sequence for the skill to function properly. There are tutorials on these forums and on Yanfly's website: http://yanfly.moe/2015/10/11/yep-4-action-sequence-pack-1/
I'm still not quite used to working with JavaScript, but I think you should remove these colored brackets from your code:
Right now, the brackets should cause the function to get executed on the spot with no arguments passed (which causes 'm' in your function to stay 'undefined').
Without the brackets, the function should be treated like an ordinary object and passed to forEach as intended.

$gameParty.members().forEach(function(m){
m.gainHp(0.5*(m.mhp));
m.gainMp(0.5*(m.mmp));
}());
Thank you all for your replies, but Another Fen had the answer I was looking for.

Original thread: https://forums.rpgmakerweb.com/threads/percentage-healing-script-call.80364/