If you're just trying to be able to access simple data across screens, static variables seem like the most straightforward solution. It's fine if you've never used them before, they're very easy to use once you get used to them. :)
The first thing to do is create a class that will hold your static variables (yes, this means writing a new script and putting it in your Scripts folder). It's possible to add new static variables on a class you're already using, but if you're just learning I would recommend keeping things like that separated so it's more organized.
public class GameValues {
public static int score { get; set; }
// You can add other static variables here.
}
Notice I didn't inherit from MonoBehaviour. This is fine because we don't need to add this script to a GameObject, it's just going to be used to store our data. Now if we need to change or read the score, we can do it like this.
public class Example : MonoBehaviour {
public int scoreLimit = 100;
private void Update () {
/*
* When accessing static members of a class, no object reference is needed.
* Instead you access it as though it were a member of the class.
*/
int currentScore = GameValues.score;
if (Input.GetKeyDown (KeyCode.Space) && (currentScore < scoreLimit)) {
GameValues.score += 1;
}
}
}
Obviously this is a rather silly example, but you get the idea. If you'd like to do some further reading, here is the official Microsoft documentation on the static
keyword.
Happy coding!