When I unpack prefab, high score system loses ability to count

I am having a weird problem, and this is alot of code to go through but it really all has something to do with the ScoreBoardEntryData, ScoreBoardUI; and the AddScore void in the Scoreboard.cs script. But, as soon as I unpack the prefab that it is in, it loses its ability to number going down as a high score table should. I got this code from a tutorial and can get it to work perfectly fine so long as I do not need to replicate it, but I need multiple high score boards and it is so locked in. I cannot figure out why it loses the ability to count when the prefab is unpacked. It is so buggy. If I undo the unpacks, it still cannot count. And I cannot even reimport it back in functional. It loses ability to count freshly imported after that as well.

Scoreboard.cs:

using System.IO;
using UnityEngine;

namespace DapperDino.Scoreboards
{
    public class Scoreboard : MonoBehaviour
    {
        [SerializeField] private int maxScoreboardEntries = 5;
        [SerializeField] private Transform highscoresHolderTransform = null;
        [SerializeField] private GameObject scoreboardEntryObject = null;

        [Header("Test")]
        [SerializeField] private string testEntryName = "New Name";
        [SerializeField] private int testEntryScore = 0;

        private string SavePath => $"{Application.persistentDataPath}/highscores.json";

        private void Start()
        {
            ScoreboardSaveData savedScores = GetSavedScores();

            UpdateUI(savedScores);

            SaveScores(savedScores);
        }

        [ContextMenu("Add Test Entry")]
        public void AddTestEntry()
        {

            string json = File.ReadAllText(Application.dataPath + "/NewName.json");
            NameJSON Name = JsonUtility.FromJson<NameJSON>(json);
            string testEntryName = Name.name;
          
            json = File.ReadAllText(Application.dataPath + "/ScoreNumber.json");
            ScoreJSON ScoreNumber = JsonUtility.FromJson<ScoreJSON>(json);
            int testEntryScore = ScoreNumber.Amount;
          
          
            AddEntry(new ScoreboardEntryData()
          
            {
              
                entryName = testEntryName,
                entryScore = testEntryScore
            });
        }

        public void AddEntry(ScoreboardEntryData scoreboardEntryData)
        {
            ScoreboardSaveData savedScores = GetSavedScores();

            bool scoreAdded = false;

            //Check if the score is high enough to be added.
            for (int i = 0; i < savedScores.highscores.Count; i++)
            {
                if (testEntryScore > savedScores.highscores[i].entryScore)
                {
                    savedScores.highscores.Insert(i, scoreboardEntryData);
                    scoreAdded = true;
                    break;
                }
            }

            //Check if the score can be added to the end of the list.
            if (!scoreAdded && savedScores.highscores.Count < maxScoreboardEntries)
            {
                savedScores.highscores.Add(scoreboardEntryData);
            }

            //Remove any scores past the limit.
            if (savedScores.highscores.Count > maxScoreboardEntries)
            {
                savedScores.highscores.RemoveRange(maxScoreboardEntries, savedScores.highscores.Count - maxScoreboardEntries);
            }

            UpdateUI(savedScores);

            SaveScores(savedScores);
        }

        private void UpdateUI(ScoreboardSaveData savedScores)
        {
            foreach (Transform child in highscoresHolderTransform)
            {
                Destroy(child.gameObject);
            }

            foreach (ScoreboardEntryData highscore in savedScores.highscores)
            {
                Instantiate(scoreboardEntryObject, highscoresHolderTransform).GetComponent<ScoreboardEntryUI>().Initialise(highscore);
            }
        }

        private ScoreboardSaveData GetSavedScores()
        {
            if (!File.Exists(SavePath))
            {
                File.Create(SavePath).Dispose();
                return new ScoreboardSaveData();
            }

            using (StreamReader stream = new StreamReader(SavePath))
            {
                string json = stream.ReadToEnd();

                return JsonUtility.FromJson<ScoreboardSaveData>(json);
            }
        }

        private void SaveScores(ScoreboardSaveData scoreboardSaveData)
        {
            using (StreamWriter stream = new StreamWriter(SavePath))
            {
                string json = JsonUtility.ToJson(scoreboardSaveData, true);
                stream.Write(json);
            }
        }
    }
}

ScoreboardEntryData.cs:

using System;

namespace DapperDino.Scoreboards
{
    [Serializable]
    public struct ScoreboardEntryData
    {
        public string entryName;
        public int entryScore;
    }
}

ScoreboardEntryUI.cs:

using TMPro;
using UnityEngine;
using System.IO;

namespace DapperDino.Scoreboards
{
    public class ScoreboardEntryUI : MonoBehaviour
    {
        [SerializeField] private TextMeshProUGUI entryNameText = null;
        [SerializeField] private TextMeshProUGUI entryScoreText = null;
      

        public void Initialise(ScoreboardEntryData scoreboardEntryData)
        {
            entryNameText.text = scoreboardEntryData.entryName;
            entryScoreText.text = scoreboardEntryData.entryScore.ToString();
          
        }
    }
}

ScoreboardSaveData.cs:

using System;
using System.Collections.Generic;

namespace DapperDino.Scoreboards
{
    [Serializable]
    public class ScoreboardSaveData
    {
        public List<ScoreboardEntryData> highscores = new List<ScoreboardEntryData>();
    }
}

I ran all of the script through a basic test and noticed that it will only put out a functioning high score system if the entry score object that has the text is made into a prefab and then loaded into the slot on the script that is the parent of it all that has the Scoreboard.cs script. But, then as soon as you unpack the prefab it never seems to function right again and you cannot rinse and repeat. It just stays the same. I just do not understand why it is so reliant on prefabs or any way around it.

I changed this greater than or less than sign to go the other way around and got the script to start ordering numbers the other way now. So maybe I am near to figuring something out.

//Check if the score is high enough to be added. But, I do not think it is the index entry method, I think it has something to do with the fact that the ScoreboardEntryData.cs script was made with a public struct and that perhaps tied its functionality to a prefab and made it so picky. 
            for (int i = 0; i < savedScores.highscores.Count; i++)
            {
                if (testEntryScore < savedScores.highscores[i].entryScore)
                {
                    savedScores.highscores.Insert(i, scoreboardEntryData);
                    scoreAdded = true;
                    break;
                }
            }

I am trying to figure out if implementing OrderByDescending somehow would help, but I cannot figure out how to use it properly so far, cant get it to compile.

This is what I have tried in adding to the code.

public void AddEntry(ScoreboardEntryData scoreboardEntryData)
        {
            ScoreboardSaveData savedScores = GetSavedScores();
            scoreboardEntryData =
                savedScores.highscores.OrderByDescending(testEntryScore > savedScores.highscores.Count);

            bool scoreAdded = false;

            //Check if the score is high enough to be added.
            for (int i = 0; i < savedScores.highscores.Count; i++)
            {
                if (testEntryScore > savedScores.highscores[i].entryScore)
                {
                    savedScores.highscores.Insert(i, scoreboardEntryData);
                   
                    scoreAdded = true;
                    break;
                }

I tried this in the if statement of the AddEntry statement, was reading that instantiating an object that seems to only function as a prefab is the answer, however, I have no idea how to do that, especially with somethin like this. This did not affect it at all.

savedScores.highscores.Insert(i, scoreboardEntryData);
                    Instantiate(scoreboardEntryObject, highscoresHolderTransform).GetComponent<ScoreboardEntryUI>().Initialise(scoreboardEntryData);

I figured it out, because it seems like all high score data has to be serialized it requires a relationship with prefabs to work as I noticed going through other peoples high score systems and found that I have to have a template for my high score system that I go through a brand new process of plugging in the code and creating prefabs with different names for and it worked!

A prefab instance is just a game object that draws some of its data from the original prefab. At runtime prefabs don’t exist. If something is going wrong by unpacking a prefab, there is something seriously wrong with your code/setup.