Problem in Setting Photon Teams

Hi , i have problem with setting teams in photon. i want to set half of my players in room to be in the Blue PUN team. it’s realy simple code but acting Wierd , the code have to apply for amount of " count " but doing more and make all of my players in room turn to blue.

here is my code :

using UnityEngine;
using System.Collections;

public class AutoBalancer : MonoBehaviour {

    int count;
	void Start () 
    {
        count = (PhotonNetwork.room.PlayerCount / 2) + 1;

        foreach (PhotonPlayer player in PhotonNetwork.playerList)
        {
            count -= 1;
            if (count > 0)
            {
                player.SetTeam(PunTeams.Team.blue);
            }
        }
	}
}

Your code looks overly complicated. Also i think there is a Neutral team, i would set the red team aswell to be safe

count = Mathf.Round(PhotonNetwork.room.PlayerCount / 2.0f);

for(int i = 0; i < PhotonNetwork.room.PlayerCount; i++)
{
	var team = PunTeams.Team.blue;
	
	if(i >= count)
		team = PunTeams.Team.red;
		
	PhotonNetwork.playerList*.SetTeam(team);*

}

count = Mathf.Round(PhotonNetwork.room.PlayerCount / 2.0f);

 for(int i = 0; i < PhotonNetwork.room.PlayerCount; i++)
 {
     var team = PunTeams.Team.blue;
     
     if(i >= count)
         team = PunTeams.Team.red;
         
     PhotonNetwork.playerList*.SetTeam(team);*

}
Thanks dude this works just perfect . /Like :))