Get # of Party Members

I am performing actions based on the Party members actor IDs. However if there is no party member present in one or more of the checked party slots, the game returns an error.

How can I first check how many party members there are so I can set when to break the loop?

Below is what I'm trying to do. ( I don't need to know how to do the loop code, it's just there to give more information on what I'm doing)

I suppose I could always keep track of the # of party members in my own variable, but if there is already a way then I would rather use it.

LoopVarA = 0

NumofPartyMembers = Number of party members <--- How do I do this?

Loop

$gameParty.members()[LoopVarA]._actorId

LoopVarA = LoopVarA + 1

if LoopVarA = (NumofPartyMembers) Break Loop

End Loop
There's a function already built-in that returns the number of party members. It's called "$gameParty.size()".

The first thing you should always do is check the functions and properties of the objects you're using so you don't waste time duplicating existing code.
There's a function already built-in that returns the number of party members. It's called "$gameParty.size()".
Thanks for the help.

I was looking for that function, not trying to duplicate it.

I need help with this now,

$gameParty.members()[0]._actorId <-- This line works, but I want the 0 to be replaced with a variable

$gameParty.members()[$gameVariables(7)]._actorId <-- This returns Object is not a function, I also tried:

$gameParty.members()[$gameVariables()[7]]._actorId
You should use :

Code:
$gameParty.members()[$gameVariables.value(7)]._actorId
$gameParty should have an array of actors. do .length on it

Original thread: https://forums.rpgmakerweb.com/threads/get-of-party-members.50298/