MV How to heal the party or target based on damage inflicted.


I started using this code Naveed provided with skill core and it works like a charm but its for all party members and i see the damage dealt but i dont see heal numbers on the allies. I have little to no skill on coding. Im still getting the grasp of it. How can i make this code work for one random ally and also another one for just the user with heal numbers appear on the ally or allies after the damage appeared. Im trying to make variations of this healing method for a class all together but couldnt do it. Thanks in advance.
How can i make this code work for one random ally
Code:
<Post-Damage Eval>
let healTar = $gameParty.aliveMembers()[Math.randomInt($gameParty.aliveMembers().length)];
healTar.gainHp(X);
healTar.startDamagePopup();
</Post-Damage Eval>

and also another one for just the user
Code:
<Post-Damage Eval>
user.gainHp(X);
user.startDamagePopup();
</Post-Damage Eval>

In both cases, replace X with how much you want to heal.
Thank you so much.
Sorry for the trouble. Could you check here. This is Naveeds original code for healing all allies after damage. Your codes allowing me to see the hp numbers and working exactly as i wished. But this code does not allow me to see that. This is the version for all allies. Is there something wrong about the code that messing with the heal number appearing?


<Post-Damage Eval>
var heal = x;

var members = $gameParty.battleMembers();

for (var i = 0; i < members.length; i++) {
var ally = members;
if (ally.isDead()) continue;
ally.gainHp(heal);
ally.startDamagePopup();
ally.clearResult();
}
</Post-Damage Eval>
The only difference I see is the last line ally.clearResult()
Thank you so much. It works.
Code:
<Post-Damage Eval>
$gameParty.aliveMembers().forEach(ally => {ally.gainHp(X); ally.startDamagePopup();});
</Post-Damage Eval>

Original thread: https://forums.rpgmakerweb.com/threads/how-to-heal-the-party-or-target-based-on-damage-inflicted.161985/