How to deal with this repetitive code

I am a bit inexperienced with coding/scripting but I’m running into something where I am repeating the same thing in my code over and over.

I have a singleton “GameController” which contains a static instance of my “BaseCharacter” class. This class contains all the data on stats, experience etc.

The name of the baseClass instance is called playerData. So now I write stuff like this:

for (int x = 0; x < GameController.playerData.attributes.Length; x++)
        {
            if (GameController.playerData.attributes[x].Name == name)
            {
                if (GameController.playerData.attributes[x].BaseValue > 1)
                {
                    //Update data values
                    GameController.playerData.attributes[x].BaseValue--;
                    _statPointsLeft++;
                    UpdateStats();

                    //Show new values
                    pointsDisplay.text = "POINTS LEFT: " + _statPointsLeft;
                    attributeDisplayButtons[x].text = GameController.playerData.attributes[x].BaseValue.ToString();
                    UpdateVitalsAndSkillsText();
                }
            }
        }

GameController.playerdata. is repeated over and over in stead of just using one variable.

So the question is: am I doing something wrong/inefficient here or is this just the way it is with statics?

I’ve been experimenting with another instance of the class and then synchronizing the data but this seems complex and not very practical. Also on the web I didn’t find the solution.

var playerAttributes = GameController.playerData.attributes;

that’s all you gotta do.
it won’t create a “new” variable, it will reference the same attributes.