How to keep track of score between Scenes?

This problem is really bugging me, any help would be appreciated!

Script #1

using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;


public class Score : MonoBehaviour
{

    public Transform player;
    public Text scoreText ;
    static float zPos;



    void Update()
    {

        zPos = 1 + player.position.z / 2;
        scoreText.text = zPos.ToString("0");
        PlayerPrefs.SetFloat("theScore", zPos);


        
        if (FindObjectOfType<GameManager>().GameEnds == true)
        {
            Destroy(scoreText);
        }
     
    }
}

Script #2

using UnityEngine;
using UnityEngine.SceneManagement;


public class GameManager : MonoBehaviour
{
    public bool GameEnds = false;

    public GameObject levelComplete;

    public GameObject GameOverAn;

    public GameObject pauseMenuUI;

    public static bool pauseMenu;

    public void GameOver()
    {


        if (GameEnds == false)
        {
            GameEnds = true;
            GameOverAn.SetActive(true);
            Destroy(levelComplete);

        }
    }

    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (pauseMenu)
            {
                Resume();
            }
            else
            {
                Pause(); ;
            }

        }

    }

    public void Resume()
    {
        pauseMenuUI.SetActive(false);
        Time.timeScale = 1f;
        pauseMenu = false;
    }

    void Pause()
    {
        pauseMenuUI.SetActive(true);
        Time.timeScale = 0f;
        pauseMenu = true;
    }

    void RestartGame()
    {

        SceneManager.LoadScene(SceneManager.GetActiveScene().name);

    }

    public void NextLevel()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }

    public void LevelComplete()
    {

        levelComplete.SetActive(true);
        Destroy(GameOverAn);

    }
}

Note: I am a beginner casually looking for answers from similar questions, but nothing that i found was helpful (since i am not very familiar with complicated code).

You can tell Unity not to delete certain objects when scenes are loaded and unloaded

//this game object will not get destroyed between scene loading
void Awake()
{
    DontDestroyOnLoad(gameObject);
}

You have to be careful with using this. Because if an object is not destroyed, you might get duplicates of it, because a new one will get spawned when a scene loads. You might want to use Singletons.

https://unity3d.com/learn/tutorials/projects/2d-roguelike-tutorial/writing-game-manager

But the score is based on the position of z axes , so either way it’ll go back to 0, because my player always starts at position 0 of the z axes.

I know I might get alot of hate for this, but could a singleton be the answer?