What if nobody is in the 2nd slot?

So earlier, I asked for a script that collects the ID of the 2nd party member. Here is the script I use:

Code:
$gameParty.members()[1]._actorId

But if I activate it and nobody is in the slot:

upload_2019-11-28_22-16-41.png


How can I fix this?

Edit: Nevermind, I solved it by checking to see if the 2nd actor is in the party.
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/what-if-nobody-is-in-the-2nd-slot.115748/