How do I stop adding to a variable?

How do I stop adding to score once something happens? For example, once my player dies, how do I stop the score from continuing to add?

public int score;
    
    void Update()
     {
    score++; 
    }

I think this is basic programming knowledge. Please try to learn a programming language before jumping into Unity (you can start with C/C++ since Unity uses C# and they have little difference)

Basically what you would want to do is put an if statement instead of simply increase the score. Example:

    public int score;
    public bool isAlive;

	void Start()
    {
        isAlive = true;
    }


    void Update()
    {
        if (isAlive)
            score++;
        else
            // ...
            // shows game over screen with max score, etc
    }