How to return which party member has highest parameter/variable/whatever?

Hi! I'm struggling to find something that would allow me, for example, to return which party member has the highest atk (and then store their ID in a variable).

One instance where I need this is in dialogue scenes, where the actor with the highest atk will be the one doing all the talking.

I don't even know where to start. Any ideas? Is this even feasible?
Code:
var currentStrongestActor = $gameParty.members(0);
var currentStrongestAtk = currentStrongestActor.atk;
$gameParty.members().forEach(function(a) {
  if (a.atk > currentStrongestAtk) {
    currentStrongestAtk = a.atk;
    currentStrongestActor = a;
  };
});
If you do it this way, currentStrongestActor stores the value of the party member with the highest atk. All you have to do is use that actor face name (currentStrongestActor.faceName) to display messages.

You can use a script call and show that actor face. To find out more about MV script calls you can take a look at this thread. The script call used to display messages is included there, it also shows where you are supposed to use that face name.
This is excellent, thank you! More than just face, I'll have to handle that party member in various ways, but getting their ID is the only thing I was missing. Thank you!

Well, I do have one more little thing to ask. How long will a var (like currentStrongestActor) be stored? Only for that specific script? For that event? For the whole game until it's updated again?
It has a local scope, if you want to use it somewhere else just use this:
Code:
$gameVariables.setValue(variableID, currentStrongestActor)
This goes below the previous part. Be sure to not use "variableID" but a real variable ID instead (a number).

EDIT: do not misuse this though, the strongest party member is something that might change with time. Be sure to perform that check again before using that variable. However, using it this way allows you to call for a common event every time without having to write the same script call multiple times.
You really helped me out here. Thanks!
@adamspecial If your query is fully resolved, please Report your post and ask for the thread to be closed. Mods may not see an individual post but will see a Report.
Thanks.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-return-which-party-member-has-highest-parameter-variable-whatever.109025/