Reset Networking Gametype Values

Dear Community,

I want to hide a single Button in a Script (not mine, i have to change it).
The Script is working for a Networking Gametype

Whats the Goal here?

I have a Networking Game for 2 Players. The Scriptsetup is Teambased. When a red team Player has joined in my case, no other one should join this red team.

I hide the Button or in this case here i simply show a Label first.

I STUCK HERE:
the label shows of in my network like i want it to but remains because values have to be reset on Disconnection.
I tried OnPlayerDisconnect and the RPC in script => dont works

I need help in that script to reset the State for other Players when a Player leaves its choosen selection…
See script or ask.

Now i need a way to manage a disconnection during team selection.
Example:
When a Player chooses red, the other connected Player gets the label in his teamselection. (see script)

Now, when the red one disconnects, the Label remains forever until server is shutdown. I tried different things but i do not find a way to update this during selection state…

//some variables

using UnityEngine;
using System.Collections;

/// <summary>
/// This script is attached to the SpawnManager and it allows
/// the player to spawn into the multiplayer game.
/// </summary>


public class SpawnScript : MonoBehaviour {
	
	//Variables Start___________________________________
	
	//Used to determine if the palyer needs to spawn into
	//the game.
	
	private bool justConnectedToServer = false;
	
	private int redcount = 0;
	private int bluecount = 0;
	
	private bool disableRed = false;
	private bool disableBlue = false;
	
	
	//Used to determine which team the player is on.
	
	public bool amIOnTheRedTeam = false;
	
	public bool amIOnTheBlueTeam = false;


//The Main Part of the Script-----------------------------------------------------------------

void Awake()
	{

			redcount = 0;
			bluecount = 0;
			disableBlue = false;
			disableRed = false;
			
	}
	
	// Use this for initialization
	void Start () 
	{
	
	}
	
	// Update is called once per frame
	void Update () 
	{
		if(redcount >= 1)
		{
			disableRed = true;
		}
		if(bluecount >= 1)
		{
			disableBlue = true;
		}
		if(redcount == 0)
		{
			disableRed = false;
		}
		if(bluecount == 0)
		{
			disableBlue = false;
		}
		
		
	}
	
	
	void OnConnectedToServer ()
	{
		
		justConnectedToServer = true;
		
	}
	
	void OnPlayerConnected(NetworkPlayer networkPlayer)
	{
		networkView.RPC ("TellPlayerCountsEverywhere", RPCMode.AllBuffered, redcount,bluecount);
		networkView.RPC ("TellPlayerLockEverywhere", RPCMode.AllBuffered, disableRed,disableBlue);
	}
	


	void JoinTeamWindow (int windowID)
	{
			//If the player clicks on the Join Red Team button then
			//assign them to the red team and spawn them into the game.
		if(disableRed == true)
		{
			GUILayout.Label ("Team RED allready used!");
			
		}
		
		if(GUILayout.Button("Join Red Team", GUILayout.Height(buttonHeight)))
		{
			redcount++;
			
			amIOnTheRedTeam = true;
			
			justConnectedToServer = false;
			
			SpawnRedTeamPlayer();
			
			networkView.RPC("TellPlayerCountsEverywhere",RPCMode.AllBuffered,redcount,bluecount);
			
		}
		
			//If the player clicks on the Join Blue Team button then
			//assign them to the blue team and spawn them into the game.
			
		if(disableBlue == true)
		{
			GUILayout.Label ("Team BLUE allready used!");
			
			
		}
		
		if(GUILayout.Button("Join Blue Team", GUILayout.Height(buttonHeight)))
		{
			bluecount++;
			
			amIOnTheBlueTeam = true;
			
			justConnectedToServer = false;
			
			SpawnBlueTeamPlayer();
		
			networkView.RPC("TellPlayerCountsEverywhere",RPCMode.AllBuffered,redcount,bluecount);
			
		}
		
			
	}


//the Test RPCs--------------------------------------------------------------------------------

[RPC]
	void TellPlayerCountsEverywhere(int red, int blue)
	{
		redcount = red;
		bluecount = blue;
	}
	
	
	[RPC]
	void TellPlayerLockEverywhere(bool red, bool blue)
	{
		disableRed = red;
		disableBlue = blue;
	}

//This one i setup for the reset if it may work this way---------------------------
	
	[RPC]
	void ResetValuesOnDisconnection(int red, int blue)
	{
		bluecount = blue;
		redcount = red;
		
		if(red >= 1)
		{
			red = 0;
			disableRed = false;
		}
		if( blue >= 1)
		{
			blue = 0;
			disableBlue = false;
		}
	}

tried another thing:

does not work…

What can i do to update the functionality on the other clients?

void Awake()
	{

			redcount = 0;
			bluecount = 0;
			disableBlue = false;
			disableRed = false;
			
	}



void Update () 
	{
		if(redcount >= 1)
		{
			disableRed = true;
		}
		if(bluecount >= 1)
		{
			disableBlue = true;
		}
		if(redcount == 0)
		{
			disableRed = false;
		}
		if(bluecount == 0)
		{
			disableBlue = false;
		}
		
		ResetOnDisconnection();
	}


void OnPlayerDisconnected()
	{
		enableReset = true;
	}




void ResetOnDisconnection()
	{
		if(enableReset == true)
		{
			if( amIOnTheRedTeam == true)
			{
				redcount = 0;
				disableRed = false;
			}
			
			if(amIOnTheBlueTeam == true)
			{
				bluecount = 0;
				disableRed = false;
			}
			
		networkView.RPC("ResetCountsEverywhere",RPCMode.Others,redcount,bluecount);
		networkView.RPC("ResetLocksEverywhere",RPCMode.Others,disableRed,disableBlue);
			
		enableReset = false;
		}
		
	
	}
	
	[RPC]
	void TellPlayerCountsEverywhere(int red, int blue)
	{
		redcount = red;
		bluecount = blue;
	}
	
	
	[RPC]
	void TellPlayerLockEverywhere(bool red, bool blue)
	{
		disableRed = red;
		disableBlue = blue;
	}
	
	[RPC]
	void ResetCountsEverywhere(int red, int blue)
	{
		redcount = red;
		bluecount = blue;
		
	}
	
	
	[RPC]
	void ResetLocksEverywhere(bool red, bool blue)
	{
		
		disableRed = red;
		disableBlue = blue;
	}
	
	
	
}

??no one?