How to change scene when reach certain score

I’ve tried to find a way online, and none seems to fit how I would like the script to run.
I would like the script to change to a level complete scene where you collect a certain amount of items and get a certain score.
I’ve gone about it by attempting:

using UnityEngine;
using UnityEngine.SceneManagement;
public class GameWin : MonoBehaviour
{

string sceneName
    
    void Update()
    {
        if (ScoringSystem.theScore >= 3)
        {
            SceneManager.LoadScene(sceneName);
        }
    }
}

ScoringSystem and theScore come from another script that keeps count of score using a UI
any suggestions?

Hello! This is a standard answer

For this kind of problems, where the code has no scripting errors, and something is not working as you pretend. Is almost impossible to detect without testing by your hand. The only solution is to DEBUGG THE CODE WHILE RUNNING .

Any kind of program/script/game will need to be debugged several times during development process, mainly when this kind of errors appear. When debugging, you will see the value of each variable while is executing , when you need it, so is the only way to see what variable is not as you think it should be, for example an int number is not the value you think, or a string is not as you think, or something is different from what you think.

Debugg while running is very simple, no need to learn anything, just click the debugg button and press play. There are so many tutorials on youtube about debugging (Unity + Visual Studio works fine). I suggest you to spend 10 minutes learning to do it and debugg your code to find where is the problem.

Good Luck!