How to stop counting point when player dies (Destroy)


In my game, I’d like to stop counting points when the player’s y is -4. When the pink and red balls fall off the Plane the player gets points. But it seems a bit strange to be able to collect points after the player dies.

The game is over, but the points are still pouring in.

This is the code for the player:

     if (transform.position.y < -4)     {        Destroy(gameObject);        gameManager.GameOver();     } 

And in the GameManager.cs I have this:

   public bool isGameActive;     public void UpdateScore(int scoreToAdd)    {       score += scoreToAdd;       scoreText.text = "POENG: " + score;    }     public void GameOver()    {       isGameActive = false;       restartButton.gameObject.SetActive(true);       gameOverText.gameObject.SetActive(true);    } 

And this is the code for adding points when the enemies fall over the edge:

    if (transform.position.y < -4)     {        Destroy(gameObject);        gameManager.UpdateScore(pointValue);     } 

How can I make the game stop counting points when the player dies?