Hello, I believe the error comes in this line, local PokemonNumber = #PokemonList[CurrentPokemon], you are trying to get length but it returns nil, Instead try this, local PokemonNumber = table.find(PokemonList, CurrentPokemon)
Tell me if that fixes it.
As they said, PokemonList is what’s called an array which just means it’s an ordered list of values, each one having an index starting at one, and counting upwards for every additional element in the array. Because of this, in order to retrieve a value from it, you have to give the index position (a number) of the item in the array. Dictionaries are lists of keys who’s indexes can be strings, numbers, or objects.
Now from looking at your code it seems like you understood this concept for the most part as you were at times indexing the array with a number value, but you’d frequently put #PokemonList["Mudkip"]. Now what’s going on here is the script tries to search for the index "Mudkip" in the array (which we’ve already established we can only index ordered arrays with numbers, and dictionaries with strings), and then it was trying to call #nil because PokemonList["Mudkip"] returns nil.
I know it’s quite the long explanation, but I hope this helps you better understand arrays and how to use them, as well as the quirks of debugging odd errors like these! Order of operations matters, and even a seasoned programmer may have to do a double take to figure out why exactly the error is written our the way it is.