# Static variable not holding its value

I am creating a real time multiplayer game in Unity 3d. When a game ends I set a static boolean value called "waitingToEndGame" to true. In Update() it waits a few seconds before moving to a new scene like this:

if (waitingToEndGame)
{
waitTime += Time.deltaTime;
if (waitTime >= 5f)
{
showGameScores = false;
waitingToEndGame = false;
if (type == "Multiplayer") MultiplayerController.Instance.LeaveGame();
GameObject levelManager = GameObject.Find("Level Manager");
}
DisableAllMovingObjects();
}


My problem is that even though I am setting the boolean value to true it acts as if it doesn't change and it doesn't make it into the code above to move to the main menu. I even had debug statements printing here as well and they seem to just suddenly stop.

• Please debug you code first and then ask question. Which IDE do you use? Debug will clearly shows you any exceptions and stacktrace. Using information provided we can just guess what is going on – Dzianis Yafimau Apr 8 '16 at 7:48
• @DenisEfimov Of course I debugged before asking the question. I'm using Visual studio. My issue is it works fine when I am testing this in a single player game, but multiplayer has issues and I cannot debug in multiplayer. – saboehnke Apr 10 '16 at 18:32
• I think there is not enough info provided to help with your issue. But you can add logging and see what happens on remote clients. – Dzianis Yafimau Apr 10 '16 at 18:37