In-game counter stops counting when game is built?

Thanks for reading my message. In my game, I have a counter set up which displays the number of checkpoints in my level, and when the player reaches each checkpoint, the counter deducts 1 from the count. this works perfectly in the editor as well as when the game is built but once you die and the level is restarted, then the counter will never count down. What is confusing me is that this is only a problem once the game is built, not in the editor (which runs exactly how I anticipated). any help will be appreciated! The script below is being used by other scripts, but literally just to enable/disable it (for instance, when the player dies, I use “counter.enabled = false” to hide the counter, then the player can press the restart button, then the counter is shown upon the reloaded level if that makes sense)

Here is the counter script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Count : MonoBehaviour 
{
	public Text counterText;
	public int numberOfCheckpoints;

	void Start ()
	{
		SetCountText ();
	}

	void OnTriggerEnter (Collider other)
	{
		if (other.gameObject.CompareTag ("Checkpoint")) 
		{
			numberOfCheckpoints = numberOfCheckpoints - 1;
			SetCountText ();
		}
	}

	void SetCountText ()
	{
		counterText.text = "Checkpoints: " + numberOfCheckpoints.ToString ();
	}
}

Do you ever set numberOfCheckpoints back to its starting value when the player presses the restart button?

You could add another member variable for the maximum number of checkpoints and set numberOfCheckpoints equal to that when the level starts.

If you are enabling/disabling the counter when the game starts and ends you could use the OnEnable() function instead of Start():

 public class Count : MonoBehaviour 
 {
     public Text counterText;
     public int numberOfCheckpoints;
     public int maxNumberOfCheckpoints;
 
     void OnEnable()
     {
         numberOfCheckpoints = maxNumberOfCheckpoints;
         SetCountText ();
     }