How can I get a list of every connected player?

I’ve spent longer than I want to admit on this and tried just about every snippet of code I can find, I have a Server Only GameManager and I want it to be able to find every player connected to the game so I can spawn a new object at each players location when the game starts up.

My GameManager extends NetworkBehaviour and inside is a function called GetNumConnectedPlayers which (for now) I’m checking every frame on Update until it hits the number of players I’m expecting, which is 2, at that point it’ll spawn the objects and set a flag so it only spawns once. All that will be refactored later, at this point though, I can’t even keep track of the players in the game.

Some things I’ve tried are:

int GetNumConnectedPlayers() {
    return Network.connections.Length;
}
    int GetNumConnectedPlayers() {
       
        NetworkManager networkManager = NetworkManager.singleton;
        List<PlayerController> players = networkManager.client.connection.playerControllers;
        return players.Count;
}
    int GetNumConnectedPlayers() {
       
        int playerCount = 0;
        for (int i = 0; i < NetworkServer.connections.Count; i++) {
            NetworkConnection conn = NetworkServer.connections[i];
            foreach (PlayerController player in conn.playerControllers) {
                playerCount++;
            }
        }  
        return playerCount;
}
    int GetNumConnectedPlayers() {
       
        GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
        return players.Length;
}

They always return 1. I then tried using listeners and just keeping track of players as they connect:

    void Start() {
        NetworkServer.Listen(9000);
        NetworkServer.RegisterHandler(MsgType.Connect, OnConnected);
    }

    void OnConnected(NetworkMessage player)
    {
        Debug.Log("Player connected ");
        playerCount++;
    }

But that function never seems to fire.

I can see the players are actually spawning as they’re both in the hierarchy and I can see them in the scene. At this point I’m pretty much out of ideas, can anyone see what I’m doing wrong?

I am not sure, but isnt Network.connections an array and if the length of the array is 1 then it contains two values, Player 0 and Player 1 since arrays start at 0.