Can someone help me out with my code. Error

a

Did you assign a value to your gameSave variable in the inspector?

There is no space for it i suppose because its not a MonoBehaviour script

Ah, I didn’t notice that.

In that case, you need to give it a value through scripting. Most likely in the Start function, you would want to add:

gameSave = new GameSave();

The reason you got an error is because you created a variable and tried to access it before giving it a value.

While it probably won’t be useful here, you can expose non-MonoBehaviour classes in the inspector by adding System.Serializable.

It worked thank you!