Variable is showing up every frame except the frame I am calling the function

I create a variable: [SerializeField] TextMeshProUGUI levelText and I double check that I have the component set in Unity. Even when running, it is set.

I run a debug.log to check levelText and it tells me it has the game object stored as its value. I run this debug.log in the update function and it works every frame (callback?)

I then run some code to set the text of my game object and it throws an error:
NullReferenceException: Object reference not set to an instance of an object
PanelManager.ChangePanel () (at Assets/Coding Scripts/PanelManager.cs:70)

So I double check everything at line 70 and everything else has a value, but when I debug.log the levelText, it is null.

If I unpause unity to let it continue running, the counter on the debug.log from the update function still works and my levelText is found again.

I have tried an if statement to catch if its null and set it equal to the stored value, but that is also not working.

I am trying to figure out what I am doing wrong, but looking through the code, I cannot find anything. The line that’s throwing the error looks like this:
levelText.text = playerDataSelected[“level”].ToString();

using a hashtable to store some info.

Is there something I might be missing and forgetting about? Why is the value found except when this function is being called?

Thanks for any help/ advice!

For those who need it:

I was calling this function from a button on a prefab instantiated into the scene. Since the prefab was the object assigned to the button, the prefabbed object did not have the assigned values like the one in the actual game scene, so I just had to get a reference to the one in the game scene, not the prefab. Once I referenced the one in the scene, everything worked perfectly.