I need help with a win/lose script.

I am making a pong clone and can’t find anything online about a win or lose screen. For example, if the ball moves off of one side of the screen, it will say “You lose” and bring up a restart button, but if it goes off the other side, it says “You Win” and also brings up a restart button.

If you wouldn’t mind keeping this script (if any is actually needed) to C# please

P.S. I am making it in 3d

Here you go, I wrote for you:

using UnityEngine;
using UnityEngine.UI;

public class GameState : MonoBehaviour
{
    public Transform player1, player2;
    float maxY, minY;

    public Text output;
    public Button btn;

    void Awake()
    {
        //Compensate camera position and translate to world coords
        Vector3 hBuffer = new Vector3(
            0, 
            Screen.height, 
            -Camera.main.transform.position.z);
        
        //Get Max
        maxY = Camera.main.ScreenToWorldPoint(hBuffer).y;
        //Get Min
        minY = -maxY;
    }

    //Predicate (Condition)
	bool Win()
	{
        return player1.position.y > maxY || player1.position.y < minY;
	}

	//Predicate (Condition)
	bool Lose()
	{
		return player2.position.y > maxY || player2.position.y < minY;
	}

    void Update()
    {
        if(Win())
        {
            output.text = "You Lose...";
            btn.gameObject.SetActive(true);
        }
		else if (Lose())
		{
			output.text = "You Win!!!";
            btn.gameObject.SetActive(true);
		}
        else
        {
            output.text = "";
            btn.gameObject.SetActive(false);
        }
    }
}

UI Tutorials

Good luck!
Ping-Pong Scene