Displaying a Score in a Game Over Scene, taken from the MainGame Scene?

Hey guys, first time posting here! I’m currently doing an Infinite Runner and the score is currently based off how far the player has gotten from the starting point. Anyway, I’m using PlayerPrefs to grab this score and then display it in a different Scene (my Game Over Scene). It’s also worth mentioning that this method DID work when I was basing score off of time survived, but now I’m getting an error saying ‘Object reference not set to an instance of an object’. I think Unity is having trouble getting the info from the player. Anyway, here are the scripts I’ve been using.

Script that is creating then displaying the score in the main game (THIS WORKS).

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class GameManager : MonoBehaviour {

	public Transform player;
	public Text distanceText;
	public int score;


	void onDisable () {
		
		PlayerPrefs.SetInt ("Score", (int)score);
		
	}

	void Update () {
		distanceText.text = Mathf.FloorToInt(player.position.x + 5f) + "m";
		score = Mathf.FloorToInt(player.position.x + 5f);
	}



}

This is the script (currently not working) for the game over screen, the problem is coming from the code within void Update.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class GOverController : MonoBehaviour
{

		int score = 0;
		Text finalDistanceText;

		void Awake ()
		{
				finalDistanceText = GetComponent <Text> ();
		}

		void Start ()
		{
				
				score = PlayerPrefs.GetInt ("Score");

		}
	
		void Update ()
		{
				
	finalDistanceText.text = "You Ran " + (int)score + "m"; 
		
		}



		
}

Any insight from you guys would be awesome! Thanks!

yes the error is hitting on Update but that’s because finalDistanceText does not get assigned properly in the Awake function.

stick this in after line 13:

if(finalDistanceText == null){
    Debug.Log("finalDistanceText is null");
}
else{
    Debug.Log("nope, Taxvi is a douchebag");
}