I am trying to increase a certain integer when the level is reset by the player reaching the end goal.
I set up a Gameobject that has a script attached to it to stop it from being destroyed up a new scene being loaded called “KEPT”, and added another Gameobject as a child of KEPT called “Data” that houses the script with the integer im trying to increase.
The Gameobjects are both kept upon the level resetting but the score doesn’t change and I get the error
“NullReferenceException: Object reference not set to an instance of an object
Win.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/Scripts/Win.cs:27)”
FYI Win is the script that triggers the reset of the level and sends the message to Data and should thereby increase the integer.
Any idea what i need to change, do I need to keep the object that the win script is attached to from being reloaded?