I have created this endless runner where the player have to dodge obstacles for earning points and for scoring system I have create a score manager script which is placed on back of the screen . I am able to display my score on the main screen using UI. but I want to display the score on a game over scene and also create a high score system on the game over scene.Also created public static to save the data even though it saved my data and displayed it on the game over scene but when I restarted my game the score did not start at 0 but it was the continuation of the last game score. please help me HERE IS THE SCORE MANAGER SCRIPT OF MY GAME
using UnityEngine;
using UnityEngine.UI;
public class ScoreManager : MonoBehaviour
{
public static int score = 0;
public Text scoreDisplay;
public void Update()
{
scoreDisplay.text = score.ToString();
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.CompareTag("Obstacle"))
{
score++;
Debug.Log(score);
}
}
}