0
    using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Score : MonoBehaviour
{
    float playerScore = 0;
    float highScore1 = 0;
    public Text scoreText;
    public Text highScore;

    void start ()
   {
       highScore.text = highScore1.ToString();
   }
 float Update(){

 
    playerScore += Time.deltaTime*15;
    scoreText.text = playerScore.ToString("0");

    if (playerScore >= highScore1)
    {
       highScore1 = playerScore;
       highScore.text = highScore1.ToString();
    }
    else 
    {
       highScore.text = highScore1.ToString();
    }
    return highScore1;

 }

}

I wanted to make a game that measures the time you stay alive and then displays it as a score. I also wanted to make a high score. I used this code for making it but it keeps resetting each time I restart the game. How can I make it permanent?

0 Answers0