I need a script to change the party leader on the map.

I need a script for RPG Maker VX Ace, which I believe is simple. I want a small window to open when the "A" key is pressed, allowing the selection of which character will be the leader of the group. The base of this window should be an image called "base_exchange", which should be in the Pictures folder. In addition, there are two other images, "right arrow" and "left arrow", also located in the Pictures folder. Whenever the player presses an arrow key to change the selection, the image of the corresponding arrow should decrease in opacity. Each character is represented by an item, so it is important that the script includes a section where I can associate the character ID with the corresponding item ID. Regarding navigation, only the icon of the currently selected character should appear, and the movement should include a loop. For example, if I press the left arrow key and get to the last option, it should return to the first. I will provide an image to illustrate how it should look. Before that, I would like to have the option to adjust the positions of all images and icons. In addition, I would like the option to configure SEs (sound effects) for cursor movement, confirmation and the SE that plays when the leader is changed. It should be possible to adjust not only which SE to use, but also its volume and tone. I'm not sure if there is already a similar script that I can modify, I searched extensively, but I couldn't find anything.
Worked on this today. I think it is good to what you asked for.
Spoiler: Change Party Leader Scene
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Change Party Leader Scene              ║  Version: 1.00     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║   Provide a scene to change party leader      ║    01 Mar 2025     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil                                                      ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║       Change your party leader with a new scene                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║   Config the settings below                                        ║
# ║   Changes required depending on the graphic sizes you use          ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - 01 Mar 2025 - Script finished                               ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks:                                                ║
# ║   Roninator2                                                       ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use:                                                      ║
# ║  Follow the original Authors terms of use where applicable         ║
# ║    - When not made by me (Roninator2)                              ║
# ║  Free for all uses in RPG Maker except nudity                      ║
# ║  Anyone using this script in their project before these terms      ║
# ║  were changed are allowed to use this script even if it conflicts  ║
# ║  with these new terms. New terms effective 03 Apr 2024             ║
# ║  No part of this code can be used with AI programs or tools        ║
# ║  Credit must be given                                              ║
# ╚════════════════════════════════════════════════════════════════════╝

module R2_Swap_Leader_Config
  # Button to push for the scene
  Button = :X
  # Window position X
  Window_X = 240
  # Window Position Y
  Window_Y = 160
  # Window position Width
  Window_Width = 96
  # Window Position Height
  Window_Height = 72
  # Left Arrow Graphic Name
  Left_Arrow = "Arrow_L24"
  # Right Arrow Graphic Name
  Right_Arrow = "Arrow_R24"
  # Arrow Y position offset - positive moves down
  Arrow_Offset_Y = 8
  # Banner Graphic Name
  Banner = "ChooseS"
  # Banner X Offset - positive moves to the right
  Banner_Offset_X = 8
  # Banner Y Offset
  Banner_Offset_Y = -16
  # Frame Graphic Name
  Frame = "Frame"
  # Frame X offset
  Frame_Offset_X = 4
  # Frame Y Offset
  Frame_Offset_Y = 8
  # Frames that will wait until Arrow Opacity is returned to normal
  Timer = 30
 
  # Use Item Icons
  USE_ITEMS = true
  # Actor database for what item icons to use
  Actors = { # actor id, itam for the actor
            1 => 8,
            2 => 11,
            
            }
  # icon x position
  ICON_X = 28
  ICON_Y = 12
 
end

# ╔════════════════════════════════════════════════════════════════════╗
# ║                      End of editable region                        ║
# ╚════════════════════════════════════════════════════════════════════╝

class Window_ActorSelect < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(window_x, window_y, window_width, window_height)
    @current_index = 0
    @dir = -1
    self.opacity = 0
    self.back_opacity = 0
    self.contents_opacity = 255
    create_graphics
    refresh
  end
  #--------------------------------------------------------------------------
  # * Get Window X position
  #--------------------------------------------------------------------------
  def window_x
    R2_Swap_Leader_Config::Window_X
  end
  #--------------------------------------------------------------------------
  # * Get Window Y position
  #--------------------------------------------------------------------------
  def window_y
    R2_Swap_Leader_Config::Window_Y
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    R2_Swap_Leader_Config::Window_Width
  end
  #--------------------------------------------------------------------------
  # * Get Window Height
  #--------------------------------------------------------------------------
  def window_height
    R2_Swap_Leader_Config::Window_Height
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items
  #--------------------------------------------------------------------------
  def item_max
    $game_party.members.size
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items
  #--------------------------------------------------------------------------
  def row_max
    return 1
  end
  #--------------------------------------------------------------------------
  # * Get Number of Lines to Show
  #--------------------------------------------------------------------------
  def visible_line_number
    return 1
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    return 1
  end
  #--------------------------------------------------------------------------
  # * Get Spacing for Items Arranged Side by Side
  #--------------------------------------------------------------------------
  def spacing
    return 8
  end
  #--------------------------------------------------------------------------
  # * Calculate Width of Window Contents
  #--------------------------------------------------------------------------
  def contents_width
    (item_width - spacing)
  end
  #--------------------------------------------------------------------------
  # * Calculate Height of Window Contents
  #--------------------------------------------------------------------------
  def contents_height
    item_height
  end
  #--------------------------------------------------------------------------
  # * Get Item Height
  #--------------------------------------------------------------------------
  def item_height
    (window_height - standard_padding * 2)
  end
  #--------------------------------------------------------------------------
  # * Get Item Width
  #--------------------------------------------------------------------------
  def item_width
    window_width - standard_padding * 2
  end
  #--------------------------------------------------------------------------
  # * Get Rectangle for Displaying Items
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = super
    rect.x = index * (item_width + spacing)
    rect.y = 0
    rect
  end
  #--------------------------------------------------------------------------
  # * Get Alignment
  #--------------------------------------------------------------------------
  def alignment
    return 1
  end
  #--------------------------------------------------------------------------
  # * Move Cursor Down
  #--------------------------------------------------------------------------
  def cursor_down(wrap = false)
  end
  #--------------------------------------------------------------------------
  # * Move Cursor Up
  #--------------------------------------------------------------------------
  def cursor_up(wrap = false)
  end
  #--------------------------------------------------------------------------
  # * Move Cursor One Page Down
  #--------------------------------------------------------------------------
  def cursor_pagedown
  end
  #--------------------------------------------------------------------------
  # * Move Cursor One Page Up
  #--------------------------------------------------------------------------
  def cursor_pageup
  end
  #--------------------------------------------------------------------------
  # * Move Cursor Right
  #--------------------------------------------------------------------------
  def cursor_right(wrap = false)
    @right_arrow.opacity = 50
    if index < item_max - 1
      select(index + 1)
    else
      select(0)
    end
    @current_index = index
    refresh
  end
  #--------------------------------------------------------------------------
  # * Move Cursor Left
  #--------------------------------------------------------------------------
  def cursor_left(wrap = false)
    @left_arrow.opacity = 50
    if index > 0
      select(index - 1)
    else
      select(item_max - 1)
    end
    @current_index = index
    refresh
  end
  #--------------------------------------------------------------------------
  # * Selected Actor
  #--------------------------------------------------------------------------
  def selected_actor
    return index
  end
  #--------------------------------------------------------------------------
  # * Restore Previous Selection Position
  #--------------------------------------------------------------------------
  def select_last
    select(0)
  end
  #--------------------------------------------------------------------------
  # * Selected Actor
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    actor = $game_party.members[@current_index]
    if R2_Swap_Leader_Config::USE_ITEMS == true
      icon = $data_items[R2_Swap_Leader_Config::Actors[actor.id]].icon_index
      draw_icon(icon, R2_Swap_Leader_Config::ICON_X, R2_Swap_Leader_Config::ICON_Y)
    else
      draw_actor_graphic(actor, 40, 40)
    end
  end
  #--------------------------------------------------------------------------
  # * Normal Arrow Opacity
  #--------------------------------------------------------------------------
  def normal_arrow
    @right_arrow.opacity = 255
    @left_arrow.opacity = 255
  end
  #--------------------------------------------------------------------------
  # * Arrow Opacity lower
  #--------------------------------------------------------------------------
  def arrows_dim
    return true if @right_arrow.opacity < 255
    return true if @left_arrow.opacity < 255
    return false
  end
  #--------------------------------------------------------------------------
  # * Update Cursor
  #--------------------------------------------------------------------------
  def update_cursor
    cursor_rect.empty
  end
  #--------------------------------------------------------------------------
  # * Update Cursor
  #--------------------------------------------------------------------------
  def create_graphics
    @frame_sprite = Sprite.new
    @frame_sprite.bitmap = Cache.system(R2_Swap_Leader_Config::Frame)
    @frame_sprite.x = window_x + window_width / 2 - @frame_sprite.width / 2 + R2_Swap_Leader_Config::Frame_Offset_X
    @frame_sprite.y = window_y + R2_Swap_Leader_Config::Frame_Offset_Y
    @left_arrow = Sprite.new
    @left_arrow.bitmap = Cache.system(R2_Swap_Leader_Config::Left_Arrow)
    @left_arrow.x = window_x
    @left_arrow.y = window_y + window_height / 2 - R2_Swap_Leader_Config::Arrow_Offset_Y
    @right_arrow = Sprite.new
    @right_arrow.bitmap = Cache.system(R2_Swap_Leader_Config::Right_Arrow)
    @right_arrow.x = window_x + window_width - 20
    @right_arrow.y = window_y + window_height / 2 - R2_Swap_Leader_Config::Arrow_Offset_Y
    @banner = Sprite.new
    @banner.bitmap = Cache.system(R2_Swap_Leader_Config::Banner)
    @banner.x = window_x + R2_Swap_Leader_Config::Banner_Offset_X
    @banner.y = window_y + window_height + R2_Swap_Leader_Config::Banner_Offset_Y
  end
  #--------------------------------------------------------------------------
  # * Free
  #--------------------------------------------------------------------------
  def dispose
    @frame_sprite.bitmap.dispose
    @frame_sprite.dispose
    @left_arrow.bitmap.dispose
    @left_arrow.dispose
    @right_arrow.bitmap.dispose
    @right_arrow.dispose
    @banner.bitmap.dispose
    @banner.dispose
    super
  end
end

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Update Scene Transition
  #--------------------------------------------------------------------------
  alias r2_update_swap_leader_scene   update_scene
  def update_scene
    r2_update_swap_leader_scene
    swap_leader if Input.trigger?(R2_Swap_Leader_Config::Button)
  end
  #--------------------------------------------------------------------------
  # * Swap Leader
  #--------------------------------------------------------------------------
  def swap_leader
    SceneManager.call(Scene_Swap_Leader)
  end
end

class Scene_Swap_Leader < Scene_Base
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    create_background
    @actor = 0
    @dim_arrow_op = false
    create_actor_window
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_background
  end
  #--------------------------------------------------------------------------
  # * Create Background
  #--------------------------------------------------------------------------
  def create_background
    @background_sprite = Sprite.new
    @background_sprite.bitmap = SceneManager.background_bitmap
    @background_sprite.color.set(16, 16, 16, 128)
  end
  #--------------------------------------------------------------------------
  # * Create Actor Window
  #--------------------------------------------------------------------------
  def create_actor_window
    @actor_window = Window_ActorSelect.new
    @actor_window.select_last
    @actor_window.activate
    @actor_window.set_handler(:ok,     method(:on_actor_change_ok))
    @actor_window.set_handler(:cancel, method(:on_actor_change_cancel))
  end
  #--------------------------------------------------------------------------
  # * Free Background
  #--------------------------------------------------------------------------
  def dispose_background
    @background_sprite.dispose
  end
  #--------------------------------------------------------------------------
  # * Switch to Next Actor
  #--------------------------------------------------------------------------
  def on_actor_change_ok
    @actor2 = @actor_window.selected_actor
    $game_party.swap_order(@actor, @actor2)
    $game_player.refresh
    $game_map.need_refresh = true
    on_actor_change_cancel
  end
  #--------------------------------------------------------------------------
  # * Switch to Previous Actor
  #--------------------------------------------------------------------------
  def on_actor_change_cancel
    return_scene
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias r2_update_opacity  update
  def update
    r2_update_opacity
    if @actor_window.arrows_dim && @dim_arrow_op == false
      @dim_arrow_op = true
      @dim_arrow_timer = Graphics.frame_count + R2_Swap_Leader_Config::Timer
    end
    if @dim_arrow_op == true && @dim_arrow_timer <= Graphics.frame_count
      @actor_window.normal_arrow
      @dim_arrow_op = false
    end
  end
end
Spoiler: Images
ChooseS.png
Frame.png
Arrow_R24.png
Arrow_L24.png
Worked on this today. I think it is good to what you asked for.
Spoiler: Change Party Leader Scene
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Change Party Leader Scene              ║  Version: 1.00     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║   Provide a scene to change party leader      ║    01 Mar 2025     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil                                                      ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║       Change your party leader with a new scene                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║   Config the settings below                                        ║
# ║   Changes required depending on the graphic sizes you use          ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - 01 Mar 2025 - Script finished                               ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks:                                                ║
# ║   Roninator2                                                       ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use:                                                      ║
# ║  Follow the original Authors terms of use where applicable         ║
# ║    - When not made by me (Roninator2)                              ║
# ║  Free for all uses in RPG Maker except nudity                      ║
# ║  Anyone using this script in their project before these terms      ║
# ║  were changed are allowed to use this script even if it conflicts  ║
# ║  with these new terms. New terms effective 03 Apr 2024             ║
# ║  No part of this code can be used with AI programs or tools        ║
# ║  Credit must be given                                              ║
# ╚════════════════════════════════════════════════════════════════════╝

module R2_Swap_Leader_Config
  # Button to push for the scene
  Button = :X
  # Window position X
  Window_X = 240
  # Window Position Y
  Window_Y = 160
  # Window position Width
  Window_Width = 96
  # Window Position Height
  Window_Height = 72
  # Left Arrow Graphic Name
  Left_Arrow = "Arrow_L24"
  # Right Arrow Graphic Name
  Right_Arrow = "Arrow_R24"
  # Arrow Y position offset - positive moves down
  Arrow_Offset_Y = 8
  # Banner Graphic Name
  Banner = "ChooseS"
  # Banner X Offset - positive moves to the right
  Banner_Offset_X = 8
  # Banner Y Offset
  Banner_Offset_Y = -16
  # Frame Graphic Name
  Frame = "Frame"
  # Frame X offset
  Frame_Offset_X = 4
  # Frame Y Offset
  Frame_Offset_Y = 8
  # Frames that will wait until Arrow Opacity is returned to normal
  Timer = 30
 
  # Use Item Icons
  USE_ITEMS = true
  # Actor database for what item icons to use
  Actors = { # actor id, itam for the actor
            1 => 8,
            2 => 11,
           
            }
  # icon x position
  ICON_X = 28
  ICON_Y = 12
 
end

# ╔════════════════════════════════════════════════════════════════════╗
# ║                      End of editable region                        ║
# ╚════════════════════════════════════════════════════════════════════╝

class Window_ActorSelect < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(window_x, window_y, window_width, window_height)
    @current_index = 0
    @dir = -1
    self.opacity = 0
    self.back_opacity = 0
    self.contents_opacity = 255
    create_graphics
    refresh
  end
  #--------------------------------------------------------------------------
  # * Get Window X position
  #--------------------------------------------------------------------------
  def window_x
    R2_Swap_Leader_Config::Window_X
  end
  #--------------------------------------------------------------------------
  # * Get Window Y position
  #--------------------------------------------------------------------------
  def window_y
    R2_Swap_Leader_Config::Window_Y
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    R2_Swap_Leader_Config::Window_Width
  end
  #--------------------------------------------------------------------------
  # * Get Window Height
  #--------------------------------------------------------------------------
  def window_height
    R2_Swap_Leader_Config::Window_Height
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items
  #--------------------------------------------------------------------------
  def item_max
    $game_party.members.size
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items
  #--------------------------------------------------------------------------
  def row_max
    return 1
  end
  #--------------------------------------------------------------------------
  # * Get Number of Lines to Show
  #--------------------------------------------------------------------------
  def visible_line_number
    return 1
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    return 1
  end
  #--------------------------------------------------------------------------
  # * Get Spacing for Items Arranged Side by Side
  #--------------------------------------------------------------------------
  def spacing
    return 8
  end
  #--------------------------------------------------------------------------
  # * Calculate Width of Window Contents
  #--------------------------------------------------------------------------
  def contents_width
    (item_width - spacing)
  end
  #--------------------------------------------------------------------------
  # * Calculate Height of Window Contents
  #--------------------------------------------------------------------------
  def contents_height
    item_height
  end
  #--------------------------------------------------------------------------
  # * Get Item Height
  #--------------------------------------------------------------------------
  def item_height
    (window_height - standard_padding * 2)
  end
  #--------------------------------------------------------------------------
  # * Get Item Width
  #--------------------------------------------------------------------------
  def item_width
    window_width - standard_padding * 2
  end
  #--------------------------------------------------------------------------
  # * Get Rectangle for Displaying Items
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = super
    rect.x = index * (item_width + spacing)
    rect.y = 0
    rect
  end
  #--------------------------------------------------------------------------
  # * Get Alignment
  #--------------------------------------------------------------------------
  def alignment
    return 1
  end
  #--------------------------------------------------------------------------
  # * Move Cursor Down
  #--------------------------------------------------------------------------
  def cursor_down(wrap = false)
  end
  #--------------------------------------------------------------------------
  # * Move Cursor Up
  #--------------------------------------------------------------------------
  def cursor_up(wrap = false)
  end
  #--------------------------------------------------------------------------
  # * Move Cursor One Page Down
  #--------------------------------------------------------------------------
  def cursor_pagedown
  end
  #--------------------------------------------------------------------------
  # * Move Cursor One Page Up
  #--------------------------------------------------------------------------
  def cursor_pageup
  end
  #--------------------------------------------------------------------------
  # * Move Cursor Right
  #--------------------------------------------------------------------------
  def cursor_right(wrap = false)
    @right_arrow.opacity = 50
    if index < item_max - 1
      select(index + 1)
    else
      select(0)
    end
    @current_index = index
    refresh
  end
  #--------------------------------------------------------------------------
  # * Move Cursor Left
  #--------------------------------------------------------------------------
  def cursor_left(wrap = false)
    @left_arrow.opacity = 50
    if index > 0
      select(index - 1)
    else
      select(item_max - 1)
    end
    @current_index = index
    refresh
  end
  #--------------------------------------------------------------------------
  # * Selected Actor
  #--------------------------------------------------------------------------
  def selected_actor
    return index
  end
  #--------------------------------------------------------------------------
  # * Restore Previous Selection Position
  #--------------------------------------------------------------------------
  def select_last
    select(0)
  end
  #--------------------------------------------------------------------------
  # * Selected Actor
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    actor = $game_party.members[@current_index]
    if R2_Swap_Leader_Config::USE_ITEMS == true
      icon = $data_items[R2_Swap_Leader_Config::Actors[actor.id]].icon_index
      draw_icon(icon, R2_Swap_Leader_Config::ICON_X, R2_Swap_Leader_Config::ICON_Y)
    else
      draw_actor_graphic(actor, 40, 40)
    end
  end
  #--------------------------------------------------------------------------
  # * Normal Arrow Opacity
  #--------------------------------------------------------------------------
  def normal_arrow
    @right_arrow.opacity = 255
    @left_arrow.opacity = 255
  end
  #--------------------------------------------------------------------------
  # * Arrow Opacity lower
  #--------------------------------------------------------------------------
  def arrows_dim
    return true if @right_arrow.opacity < 255
    return true if @left_arrow.opacity < 255
    return false
  end
  #--------------------------------------------------------------------------
  # * Update Cursor
  #--------------------------------------------------------------------------
  def update_cursor
    cursor_rect.empty
  end
  #--------------------------------------------------------------------------
  # * Update Cursor
  #--------------------------------------------------------------------------
  def create_graphics
    @frame_sprite = Sprite.new
    @frame_sprite.bitmap = Cache.system(R2_Swap_Leader_Config::Frame)
    @frame_sprite.x = window_x + window_width / 2 - @frame_sprite.width / 2 + R2_Swap_Leader_Config::Frame_Offset_X
    @frame_sprite.y = window_y + R2_Swap_Leader_Config::Frame_Offset_Y
    @left_arrow = Sprite.new
    @left_arrow.bitmap = Cache.system(R2_Swap_Leader_Config::Left_Arrow)
    @left_arrow.x = window_x
    @left_arrow.y = window_y + window_height / 2 - R2_Swap_Leader_Config::Arrow_Offset_Y
    @right_arrow = Sprite.new
    @right_arrow.bitmap = Cache.system(R2_Swap_Leader_Config::Right_Arrow)
    @right_arrow.x = window_x + window_width - 20
    @right_arrow.y = window_y + window_height / 2 - R2_Swap_Leader_Config::Arrow_Offset_Y
    @banner = Sprite.new
    @banner.bitmap = Cache.system(R2_Swap_Leader_Config::Banner)
    @banner.x = window_x + R2_Swap_Leader_Config::Banner_Offset_X
    @banner.y = window_y + window_height + R2_Swap_Leader_Config::Banner_Offset_Y
  end
  #--------------------------------------------------------------------------
  # * Free
  #--------------------------------------------------------------------------
  def dispose
    @frame_sprite.bitmap.dispose
    @frame_sprite.dispose
    @left_arrow.bitmap.dispose
    @left_arrow.dispose
    @right_arrow.bitmap.dispose
    @right_arrow.dispose
    @banner.bitmap.dispose
    @banner.dispose
    super
  end
end

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Update Scene Transition
  #--------------------------------------------------------------------------
  alias r2_update_swap_leader_scene   update_scene
  def update_scene
    r2_update_swap_leader_scene
    swap_leader if Input.trigger?(R2_Swap_Leader_Config::Button)
  end
  #--------------------------------------------------------------------------
  # * Swap Leader
  #--------------------------------------------------------------------------
  def swap_leader
    SceneManager.call(Scene_Swap_Leader)
  end
end

class Scene_Swap_Leader < Scene_Base
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    create_background
    @actor = 0
    @dim_arrow_op = false
    create_actor_window
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_background
  end
  #--------------------------------------------------------------------------
  # * Create Background
  #--------------------------------------------------------------------------
  def create_background
    @background_sprite = Sprite.new
    @background_sprite.bitmap = SceneManager.background_bitmap
    @background_sprite.color.set(16, 16, 16, 128)
  end
  #--------------------------------------------------------------------------
  # * Create Actor Window
  #--------------------------------------------------------------------------
  def create_actor_window
    @actor_window = Window_ActorSelect.new
    @actor_window.select_last
    @actor_window.activate
    @actor_window.set_handler(:ok,     method(:on_actor_change_ok))
    @actor_window.set_handler(:cancel, method(:on_actor_change_cancel))
  end
  #--------------------------------------------------------------------------
  # * Free Background
  #--------------------------------------------------------------------------
  def dispose_background
    @background_sprite.dispose
  end
  #--------------------------------------------------------------------------
  # * Switch to Next Actor
  #--------------------------------------------------------------------------
  def on_actor_change_ok
    @actor2 = @actor_window.selected_actor
    $game_party.swap_order(@actor, @actor2)
    $game_player.refresh
    $game_map.need_refresh = true
    on_actor_change_cancel
  end
  #--------------------------------------------------------------------------
  # * Switch to Previous Actor
  #--------------------------------------------------------------------------
  def on_actor_change_cancel
    return_scene
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias r2_update_opacity  update
  def update
    r2_update_opacity
    if @actor_window.arrows_dim && @dim_arrow_op == false
      @dim_arrow_op = true
      @dim_arrow_timer = Graphics.frame_count + R2_Swap_Leader_Config::Timer
    end
    if @dim_arrow_op == true && @dim_arrow_timer <= Graphics.frame_count
      @actor_window.normal_arrow
      @dim_arrow_op = false
    end
  end
end
If you put

Ruby:
include R2_Swap_Leader_Config

in your class definitions it saves you having to type it explicitly every time you're pulling a property out of it.
If you put

Ruby:
include R2_Swap_Leader_Config
in your class definitions it saves you having to type it explicitly every time you're pulling a property out of it.
not use to doing it that way yet. Thanks will try to remember in the future

Original thread: https://forums.rpgmakerweb.com/threads/i-need-a-script-to-change-the-party-leader-on-the-map.174997/