As Gaidzin said, Since NetworkServer.connections.Count can have nulls it doesn’t give you the actual number of connected clients. This is how I got the actual count.
int GetConnectionCount()
{
int count = 0;
foreach (NetworkConnection con in NetworkServer.connections)
{
if (con != null)
count++;
}
return count;
}
[SyncVar]
public int playersConnected;
void Update () {
if (displayPlayers) {
//only server is allowed to announce player count since he is the only that can count them
if (Network.isServer) {
playersConnected = NetworkServer.connections.Count;
}
loadingText.text = "Gathering additional players " + playersConnected + "/4";
}
}