Problem setting arrays

Hello, I’ve been struggling several days to make a proper save file for my game.
The player will take care of different animals with different values, so I’m trying to make a save file with the values of each animal store in arrays, but when storing the values I get the error "
IndexOutOfRangeException: Index was outside the bounds of the array.
Player.DataToSave () (at Assets/Scrips/DataManagement/Player.cs:98)"

That line 98 is the identity but I do not know the meaning of it. I chosed this way of storing data because there could be 1 animal or there could be 10. I really dont know what to do. I say brackeys tutorial but it wasnt really that helpful
```csharp

  • Bopongi allBopongi = GameObject.FindObjectsOfType();

      for(int i = 0; i < allBopongi.Length; i++)
      {
          identity[i] = allBopongi[i].gameObject.GetComponent<Bopongi>().identity;
          max_Hp[i] = allBopongi[i].gameObject.GetComponent<Bopongi>().maxHealth;
          hp[i] = allBopongi[i].gameObject.GetComponent<Bopongi>().health;
          exp[i] = allBopongi[i].gameObject.GetComponent<Bopongi>().experience;
          expToLevel[i] = allBopongi[i].gameObject.GetComponent<Bopongi>().expToNextLevel;
          bopongi_lvl[i] = allBopongi[i].gameObject.GetComponent<Bopongi>().bopongiLevel;
          attackP[i] = allBopongi[i].gameObject.GetComponent<Bopongi>().attackP;
    
          unconcernedExp[i] = allBopongi[i].gameObject.GetComponent<Bopongi>().unconcernedExp;
          displayExpToLvl[i] = allBopongi[i].gameObject.GetComponent<Bopongi>().displayExpToLevel;
          displayExp[i] = allBopongi[i].gameObject.GetComponent<Bopongi>().displayExp;
    
      }*
    

```

Index out of range means exactly what it says. You are trying to access an index that doesn’t exist in your array. In this case, identity probably is not a large enough array. It’s also possible all your other arrays are not large enough. If you plan to do the route you are going to save out, then you need to set the size of all those arrays to the same as the size of Bopongi.

But, I would honestly suggest looking at just saving out the Bopongi data itself instead of trying to break the data into different arrays and keep those lined up.