Win/lose screen for pong

I’m trying to add a win/lose screen for my pong game if the player or ai gets 5 points.

I added a new WinLoseScreen scene with my button ui elements in for playing/options/quitting. And I added both the win and lose screen in the sceen, and in my BallMovement script i added a function that changes the scene and enables the image based on if the player or ai wins.

    public Image WinScreen;
    public Image LoseScreen;

    private void WinLoseScreen()
    {
       
        if(playerScore.text == "5")
        {
           SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
            WinScreen.enabled = WinScreen.enabled;
        }
        else if(AIScore.text == "5")
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
            LoseScreen.enabled = LoseScreen.enabled;
        }

When I get into my game scene, i get a “The referenced script (Unknown) on this Behaviour is missing!” message, and the function doesn’t change the scene. Any guidance would be great, thank you.

Maybe you can share more details about this error message? Like full description from console

That is all that it says in the console

Did you try to check that the mono script and the class name have the same name (eg. BallMovement.cs = public class BallMovement : MonoBehaviour)? The mono script might not be linked to your GameObject.

Yes they are the same BallMovement .cs / public class BallMovement : MonoBehaviour

I have the script attached to my ball object

Usually, that warning message occurs if you have a GameObject that links a missing script or if you have a script that is unknown or missing. You can find a similar problem with different solutions regarding this issue here.

If your GameObject has the same script/component attached to it, in which way did you call your method/function WinLoseScreen() to change scenes? (I recommend using print(); or Debug.Log(); to determine whether your method/function works)