Itâs always helpful to include the error as it shows a line number. Granted, with a condensed version of your code, it wouldnât really match up, so youâd want to include what line the error is pointing to.
But for references. Both your LevelUpUI and A1 variables are references. So itâs possible either could be null.
The thing is, it was working before, but I changed a few things so that the behavior would be as I wanted. And thanks for the information about OnEnable, I had just assumed that it would run after start does, thatâs likely where the issue is popping up. Iâll get back to you after Iâve tried changing Start to Awake.
In addition, your use of Random will fail if youâre using UnityEngine.Random.Range() like that.
The Integer form of UnityEngine.Random.Range() is inclusive on the bottom exclusive on the top. Itâs designed that way so you donât have to add one to pick a random element. If you do add one, youâll eventually pick an index outside the range of your array.