title: Unity simple countdown timer not working (C#)
body: <p>I'm trying to add a simple countdown timer to my game in Unity but the timer does not go down in game.
  Programming language is C#.</p>
  <p>Here's my code:</p>
  <pre><code>using UnityEngine;
  using UnityEngine.UI;
  using UnityEngine.SceneManagement;
  using System.Collections;
  
  public class GameManager : MonoBehaviour
  {
      public static GameManager instance;
  
      private int score, highScore;
      public Text scoreText, highScoreText;
  
      private float time;
      public Text timeText;
  
      public bool started, gameOver;
  
      public GameObject gameOverPanel;
      public Text gameOverScore, gameOverHighScore;
      public Button playAgain;
  
      void Start()
      {
          instance = GetComponent&lt;GameManager&gt;();
  
          score = 0;
          scoreText.text = &quot;Score: &quot; + score;
          highScore = PlayerPrefs.GetInt(&quot;HighScore&quot;);
          highScoreText.text = &quot;Highscore: &quot; + highScore;
  
          time = 45;
          gameOver = false;
          UpdateTime();
      }
  
      void Update()
      {
          if (started)
          {
              time -= Time.deltaTime;
              UpdateTime();
              if (time &lt;= 0)
              {
                  GameOver();
              }
          }
      }
  
      public void IncreaseScore()
      {
          score++;
          scoreText.text = &quot;Score: &quot; + score;
          time += 5;
          UpdateTime();
      }
  
      public void StartTimer()
      {
          time = 45;
          started = true;
      }
  
      public void UpdateTime()
      {
          string minutes = Mathf.Floor(time / 60).ToString(&quot;00&quot;);
          string seconds = Mathf.Floor(time % 60).ToString(&quot;00&quot;);
          timeText.text = string.Format(&quot;Time: {0}:{1}&quot;, minutes, seconds);
      }
  
      private void GameOver()
      {
          time = 0;
          UpdateTime();
          started = false;
          gameOver = true;
          gameOverPanel.SetActive(true);
          gameOverScore.text = &quot;Final Score: &quot; + score;
          if (score &gt; highScore)
          {
              gameOverHighScore.text = &quot;High Score: &quot; + score;
              PlayerPrefs.SetInt(&quot;HighScore&quot;, score);
          }
          else
          {
              gameOverHighScore.text = &quot;High Score: &quot; + score;
          }
      }
  
      public void LoadGame()
      {
          SceneManager.LoadScene(&quot;GameScene&quot;);
      }
  }
  </code></pre>
  <p>I think there's an issue somewhere in the UpdateTime() function.
  I mostly followed tutorials online to get here as I'm only a beginner so please don't judge too harshly and I'll try my best to understand any answers you give me.
  I feel I haven't made any mistakes and I'm not receiving any compilation errors in my Unity console either.
  Thank you.</p>