how to make game start when both the players are connected?

i am working on a multiplayer online game, here player A creates a room and player B joins the room and plays with him, but i want game to be paused until both a and b are connected. but for somereason i am not able to make my script read if both players available in scene.

private bool p1ready,p2ready;

void Update()
{

PlayerInit();

PlayerCheck();

}

void PlayerInit()
{

if(GameObject.Find(“player1(clone)”).activeself)
p1ready = true;

if(GameObject.Find(“player2(clone)”).activeself)
p2ready = true;

}

void PlayerCheck()
{

if(p1ready && p2ready)
Time.timeScale = 1.0f;

else
Time.timeScale = 0.0f;

}

Have a look at Network.OnPlayerConnected()