How to instatiate two players simultaneoulsy before loading level

Hi, I’m new in unity networking and I’m using photon server for multiplayer game, and I’ve two scenes.

In first scene, I want a new player who has joined the room, to wait for another player to join. After total player count equals two I’m loading a new scene, where I’m actually instantiating prefab. But only the last player who has joined the room, actually able to enter in new scene, other player stuck in first scene.

The code in first scene:

void OnJoinedRoom()
{
    if (PhotonNetwork.countOfPlayers == 2)
    {
	PhotonNetwork.LoadLevel(1);
    }
}

Code in second scene:

void start() 
{
  PhotonNetwork.Instantiate("PlayerPad", Vector3.zero, Quaternion.identity, 0)

}

Does anyone know how can I make possible to enter two more player simultaneouly in new scence, after meeting some condition first. Thanks in advance.

PhotonNetwork.countOfPlayers is not the count of players in “this” room. It’s the count of players online in your game in general.
You might want to implement OnPhotonPlayerConnected(PhotonPlayer newPlayer){ … }.

If you setup MaxPlayers to 2, you can be sure that the player count is 2 when this gets called but you can also check: PhotonNetwork.playerList.Length == 2 or PhotonNetwork.otherPlayers.Length == 1.