• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Akari, Red, Kris, May - which Pokémon protagonist is your favorite? Let us know by voting in our semifinal favorite protagonist poll!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Question] Problem with this code I'm using to change abilities.

  • 30
    Posts
    300
    Days
    • Seen Jun 8, 2025
    I found this code that let's me change a pokemon's ability. The only problem is that when the player presses B it crashes the game. (other than that the code works great!
    ------------------------------------------------------------------------------------------------
    def pbChangeChoose
    pbChoosePokemon(1,3)
    pkmn=$Trainer.party[$game_variables[1]] if $game_variables[1] >= 0
    if pkmn
    options = pkmn.getAbilityList.map { |ability, _| GameData::Ability.get(ability).name }
    choice = pbMessage("What ability to you want?",options,options[pkmn.ability_index])
    pkmn.ability_index = choice
    end
    end
    --------------------------------------------------------------------------------------------------
    The Error

    comparison of String with 0 failed
    --------------------------------------------------------------------------------------------------

    I tried adding a branch in the case where choice = 0 or nil, but it didn't work.
     
    Back
    Top