[VXAce] Window_MenuStatus Error. "undefined method 'hp' for nil:NilClass"

Hi, I'm having an issue where the window status menu keeps giving me a NoMethodError when I remove a party member. It's telling me that "undefined method 'hp' for nil:NilClass". I think that means that "hp" is an undefined variable but I don't know how to fix it. Here's what I did...
Screenshot 2022-10-15 113736.png

As you can see, everything works perfectly when there's two actors in the party. But when there's only one, I get this error.
The Error.png

I'm not sure how to fix this. Here's the code that I changed.
What I changed.png

And here's what the game is taking issue with.
The Issue.png

I'm very new to RGSS3 and I don't know if I'm making some sort of rookie mistake so feel free to call me a moron all you want. But I just don't understand what I'm doing wrong.
I'm making some sort of rookie mistake
I don't know, is this a script you made yourself for showing the actors hud on the map?

It's not a problem with the base script unless you changed something there.

Tell us what scripts you have added on?
If you do not have any extra scripts added in, tell us about the event that add actors and shows the images and data and removing the actors.
Hi, I'm having an issue where the window status menu keeps giving me a NoMethodError when I remove a party member. It's telling me that "undefined method 'hp' for nil:NilClass". I think that means that "hp" is an undefined variable but I don't know how to fix it. Here's what I did...
View attachment 242808
As you can see, everything works perfectly when there's two actors in the party. But when there's only one, I get this error.
View attachment 242809
I'm not sure how to fix this. Here's the code that I changed.
View attachment 242811
And here's what the game is taking issue with.
View attachment 242810
I'm very new to RGSS3 and I don't know if I'm making some sort of rookie mistake so feel free to call me a moron all you want. But I just don't understand what I'm doing wrong.
Your problem is the line

actor2 = $game_party.members[1]

You're then calling draw_actor_hp passing in actor2 for the actor but when you only have one party member, there is no actor at index 1 of $game_party, so actor2 is nil.
I don't know, is this a script you made yourself for showing the actors hud on the map?

It's not a problem with the base script unless you changed something there.

Tell us what scripts you have added on?
If you do not have any extra scripts added in, tell us about the event that add actors and shows the images and data and removing the actors.
No, I changed the base script. The only outside script I added was to give me window names if I hold ctrl
Your problem is the line

actor2 = $game_party.members[1]

You're then calling draw_actor_hp passing in actor2 for the actor but when you only have one party member, there is no actor at index 1 of $game_party, so actor2 is nil.
Ohhh! Now I see. I'll find a different way to do that then, thank you!
If you do not have any extra scripts added in, tell us about the event that add actors and shows the images and data and removing the actors.
Sorry, I didn't respond to this part.
The event I made was a simple add and remove actors from the party command I made in a minute.
1665932887494.png

Any other change I made is in the image above of the code I edited.
Ohhh! Now I see. I'll find a different way to do that then, thank you!
Insert return unless actor2 between line 70 ~ 71 in Window_MenuStatus
Insert return unless actor2 between line 70 ~ 71 in Window_MenuStatus
Wow that worked! Thank you!
Wow that worked! Thank you!
1665945069464.png
Forgot the pic. I can't believe i forgot about the "unless" keyword

Original thread: https://forums.rpgmakerweb.com/threads/vxace-window_menustatus-error-undefined-method-hp-for-nil-nilclass.151994/