I'm trying to toggle room visibility on/off depending on the number of players in the game and whether it has started.
Basically, I want rooms to hide from the lobby if there are 4 players or the game has already started.
Unfortunately, the rooms remain always visible despite me calling the Visible method from the API.
Here is my code:
- Code: Select all
public override void UserJoined(Player player) {
if (PlayerCount < 4 && gameStarted == false)
{
joinGame(player);
}
if (PlayerCount >= 4)
{
Visible = false;
}
}
- Code: Select all
private void resetGame(Player user) {
....
gameStarted = true;
Visible = false;
Broadcast("startGame");
....
}
Any idea where I'm going wrong?