Trouble with Gameover screen.

Hi,

I’m having trouble with a gameover screen. And I’ve been working on it for around 2 weeks and I couldn’t find a solution for it. I was using Youtube and I couldn’t find it one in C# there either.
Please find bellow the C# code I am using.

Thanks in Advance.

// Start is called before the first frame update
void Start()
{
     currentHealth = maxHealth;
    healthbar.SetMaxHealth(maxHealth);
}

// Update is called once per frame
void Update()
{
  
}

void OnCollisionEnter2D(Collision2D col)
{
    if(col.gameObject.tag == "Enemy")
    {
        TakeDamage(1);
    }
}

void TakeDamage(int damage)
{
    currentHealth -= damage;
    healthbar.SetHealth(currentHealth);
}

Make a scene called GameOver.

void TakeDamage(int damage)
     {
         currentHealth -= damage;
         healthbar.SetHealth(currentHealth);
         
         if(currentHealth <= 0)
    {
    // go to gameover scene
UnityEngine.SceneManagement.SceneManager.LoadScene("GameOver")
    }
     }