void Update() { //If the UI is active //Wait for player 1 to enter input if (confirmUIActive) { if (!coroutineStarted) { StartCoroutine(WaitForInput()); //So that you don't run this coroutine many times coroutineStarted = true; } } //Check for new connection every two seconds if (timer > 0) { timer -= Time.deltaTime; } else { CheckForNewConnection(); timer = 1f; } //If player1 presses A and there are at least two players if (Input.GetButtonDown("Interact1") && GetNumOfPlayers() >= 2) { confirmUIActive = true; //Open up confirm UI confirmUI.SetActive(true); } //If you press cancel while there aren't two players, go back to selection screen if (Input.GetButtonDown("Cancel") && GetNumOfPlayers() < 2) { sceneManager.KeyboardSelect(); } }