Variables not changing when modifying them in OnMouseDown

I’m trying to create a system where each player selects a country to play as. You click on the flag of the country you want, then it deletes that country so no other player can choose it. It increases a variable representing which player the system is on, and then it goes to a different scene depending on how many players there are. The problem is that it sets the variable every time to 0, and increases it by one, so the console just puts out 1, 1, 1, 1 when I test it. As such, it never goes to the next scene. 122066-capture.pngHere is the code for the system itself:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class ButtonHandler : MonoBehaviour
{

    int currentPlayer = 0;
    int players;

    private void Start()
    {
        players = PlayerPrefs.GetInt("Players");


    }


    public enum Country { Britain, France, Germany, Switzerland };

    public Country buttonCountry;
    private void Update()
    {
        

    }

    void OnMouseDown()
    {
        currentPlayer++;
        Debug.Log(currentPlayer);
        Destroy(gameObject);
        if (currentPlayer >= players)
        {
            SceneManager.LoadScene(players);
        }


    }
}

and here is where the PlayerPrefs are defined: `using System.Collections;

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Start : MonoBehaviour {

    public int players;

    public void startGame(int playerCount)
    {
        players = playerCount;
        PlayerPrefs.SetInt("Players", players);
        PlayerPrefs.SetInt("Index", 0);
        SceneManager.LoadScene(1);
    }

    
}

There may be more going on here, but I surmise that you have a ButtonHandler class attached to multiple buttons, and as each are being initialized uniquely the default construction of each one is setting currentPlayer to zero.

While I don’t believe this is the entire solution to the design (I can’t see everything, just what code is posted), if you made playerCount static, that part of the problem would stop.