altering my custom hud so I can change character

hello everyone my game has a custom HUD which shows health magic and ammo and that's great but I would like to change character every time my player enters Cyber-Space you see in my game there are computer terminals which transport the player into a virtual world I had always intended to change the players character with a different one called avatar which would have his own attacks and stats but when I try to change character I get an error message 

[IMG]http://i229.photobucket.com/albums/ee233/smallfish1x/huderror_zps1ea52241.png[/IMG]    

obviously it must be trying to find the hp of player one so if someone could alter it so the hud can be turned of for a moment so I can change character that would be great 

here is my HUD script

#==============================================================================# ** Window_YourHUD#------------------------------------------------------------------------------# This Window displays relavent values to the player during gameplay.# by emeraldcyndaquil#==============================================================================class Window_YourHUD < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 0, 640, 64) self.opacity = 0 self.contents = Bitmap.new(640 - 32, 64 - 32) refresh end #-------------------------------------------------------------------------- # * Draw Variable #-------------------------------------------------------------------------- def draw_variable(x, y) self.contents.font.color = system_color self.contents.draw_text(x, y, 64, 32, "Ammo") # Draw HP self.contents.font.color = $game_variables[1] == 0 ? knockout_color : $game_variables[1] <= 5 ? crisis_color : normal_color self.contents.draw_text(x + 64, y, 80, 32, $game_variables[1].to_s, 2) end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear reset_variables return if !@actor draw_actor_hp(@actor, 0, 0) draw_actor_sp(@actor, 250, 0) draw_variable(440, 0) end #-------------------------------------------------------------------------- # * Reset Stored Variables #-------------------------------------------------------------------------- def reset_variables @actor = $game_party.actors[0] @old_hp = @actor ? @actor.hp : 0 @old_maxhp = @actor ? @actor.maxhp : 0 @old_sp = @actor ? @actor.sp : 0 @old_maxsp = @actor ? @actor.maxsp : 0 @old_ammo = $game_variables[1] end #--------------------------------------------------------------------------- # * Update (called once a frame) #--------------------------------------------------------------------------- def update super refresh if (@actor != $game_party.actors[0] or @old_hp != @actor ? @actor.hp : 0 or @old_maxhp != @actor ? @actor.maxhp : 0 or @old_sp != @actor ? @actor.sp : 0 or @old_ammo != $game_variables[1] or @old_maxsp != @actor ? @actor.maxsp : 0) endend#==============================================================================# ** Scene_Map#------------------------------------------------------------------------------# We've edited this to add a HUD#==============================================================================class Scene_Map #--------------------------------------------------------------------------- # * Alias Listings (fixes F12 bug) #--------------------------------------------------------------------------- unless method_defined?🙂yourhud_main) alias_method🙂yourhud_main, :main) alias_method🙂yourhud_update, :update) end #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main @yourhud = Window_YourHUD.new yourhud_main @yourhud.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update @yourhud.update yourhud_update endendand here is a copy of my game if it would help

http://s000.tinyupload.com/?file_id=14741368659685776756
Alright, so at this moment in your script, the script will always want to use the first actor in the database. When you switch, it crashes because cannot read that party member because he isn't there.

If you add "for i in 0...$game_party.actors.size" just under Def Update's "Super"

and change the "0" in "$game_party.actors[0]" to an i. It will always show the first party member in your party or none if there is none.

Hope that helps.
um ... no.

$game_party.actors[0] is not the first actor in the database. It is the first actor in your party.

If you're getting a nil class error on that line, it means you either have nobody in your party, or you haven't set the @actor variable.

How are you changing actors? If you're removing the current actor and then adding another, try to do it in the opposite order - add the new one, then remove the old one.

If that doesn't work, I'd suggest just adding a return if there's no actor so it doesn't try to update:

def update super return if !@actor # <------ new line added refresh if (@actor != $game_party.actors[0] or @old_hp != @actor ? @actor.hp : 0 or @old_maxhp != @actor ? @actor.maxhp : 0 or @old_sp != @actor ? @actor.sp : 0 or @old_ammo != $game_variables[1] or @old_maxsp != @actor ? @actor.maxsp : 0) endI've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.
Yeah, alright, that first part I got wrong, it's late I didn't read very well.

Nonetheless, the solution I gave does work. Atleast when I tested it.
thanks everyone it worked like a charm now i can change characters when ever I want 😀

Original thread: https://forums.rpgmakerweb.com/threads/altering-my-custom-hud-so-i-can-change-character.34760/