Network Connection with localhost Issues

Dear Community,

i hope someone out there is able to assist me in solving this issue:

I have a Mutliplayersetup (from GTGD Series on Youtube).

When i connect to the game two buttons are represented (blue and red team as in the Tutorial)

I want to hide one of those buttons when one Player joins this Team.

So i setup a Count and when the button is clicked the count is ++

When i run a server outside the Editor from a build and a game in teh editor, then all bools and my count are shown correctly in the Editor.

But when i do it the other way and run the server in the editor and connect from outside with a gamebuild, then the buttons still appear. When i set the count to 1 manually the buttons are gone so the script is working.

This still happens when we connect via Hamachi, the buttons stay until i set it manually to 1.

All other functions work and there are some bools too so why this one does not work?

Here is the code:

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;
	
	public int redCount = 0;
	public int blueCount = 0;
	
	
	//Used to determine which team the player is on.
	
	public bool amIOnTheRedTeam = false;
	
	public bool amIOnTheBlueTeam = false;
	
	
	//Used to define the JoinTeamWindow.
	
	private Rect joinTeamRect;
	
	private string joinTeamWindowTitle = "Team Selection";
	
	private int joinTeamWindowWidth = 330;
	
	private int joinTeamWindowHeight = 100;
	
	private int joinTeamLeftIndent;
	
	private int joinTeamTopIndent;
	
	private int buttonHeight = 40;
	
	
	//The Player prefabs are connected to these in the 
	//inspector
	
	public Transform redTeamPlayer;
	
	public Transform blueTeamPlayer;
	
	private int redTeamGroup = 0;
	
	private int blueTeamGroup = 1;
	
	
	//Used to capture spawn points.
	
	private GameObject[] redSpawnPoints;
	
	private GameObject[] blueSpawnPoints;
	
	
	//Variables End_____________________________________
	
	// Use this for initialization
	void Start () 
	{
	
	}
	
	// Update is called once per frame
	void Update () 
	{
		
	}
	
	
	void OnConnectedToServer ()
	{
		justConnectedToServer = true;	
	}
	
	
	
	void JoinTeamWindow (int windowID)
	{
		if(redCount < 1)
		{
			
			//If the player clicks on the Join Red Team button then
			//assign them to the red team and spawn them into the game.			
			if(GUILayout.Button("Join Red Team", GUILayout.Height(buttonHeight)))
			{
				redCount++;
				
				amIOnTheRedTeam = true;
				
				justConnectedToServer = false;
				
				SpawnRedTeamPlayer();
				
				
			}
			
		}
		
		if(blueCount < 1)
		{
			//If the player clicks on the Join Blue Team button then
			//assign them to the blue team and spawn them into the game.
			
			if(GUILayout.Button("Join Blue Team", GUILayout.Height(buttonHeight)))
			{
				blueCount++;
				
				amIOnTheBlueTeam = true;
				
				justConnectedToServer = false;
				
				SpawnBlueTeamPlayer();
				
			}
		}
		
	}
	
	
	void OnGUI()
	{
		//If the player has just connected to the server then draw the 
		//Join Team window.
		
		if(justConnectedToServer == true)
		{
			joinTeamLeftIndent = Screen.width / 2 - joinTeamWindowWidth / 2;
			
			joinTeamTopIndent = Screen.height / 2 - joinTeamWindowHeight / 2;
			
			joinTeamRect = new Rect(joinTeamLeftIndent, joinTeamTopIndent,
			                        joinTeamWindowWidth, joinTeamWindowHeight);
			
			joinTeamRect = GUILayout.Window(0, joinTeamRect, JoinTeamWindow,
			                                joinTeamWindowTitle);
		}
	}

Is there anyone out there who can tell me how to hide join red team or join blue team butten when allready one red or blue player is selected?
tried another thing here but does not work either…

void JoinTeamWindow (int windowID)
	{
		if(disableRed == false  disableBlue == false)
		{
			
			//If the player clicks on the Join Red Team button then
			//assign them to the red team and spawn them into the game.			
			if(GUILayout.Button("Join Red Team", GUILayout.Height(buttonHeight)))
			{
				redCount++;
				
				amIOnTheRedTeam = true;
				
				justConnectedToServer = false;
				
				SpawnRedTeamPlayer();
				
				
			}
			
		
			//If the player clicks on the Join Blue Team button then
			//assign them to the blue team and spawn them into the game.
			
			if(GUILayout.Button("Join Blue Team", GUILayout.Height(buttonHeight)))
			{
				blueCount++;
				
				amIOnTheBlueTeam = true;
				
				justConnectedToServer = false;
				
				SpawnBlueTeamPlayer();
				
			}
		}
		
		if(disableRed == true)
		{
			
			GUILayout.Label("Red Team locked!");
			
			if(GUILayout.Button("Join Blue Team", GUILayout.Height(buttonHeight)))
			{
				blueCount++;
				
				amIOnTheBlueTeam = true;
				
				justConnectedToServer = false;
				
				SpawnBlueTeamPlayer();
				
			}
			
		}
		
		if(disableBlue == true)
		{
			GUILayout.Label("Blue Team locked!");
			
			if(GUILayout.Button("Join Red Team", GUILayout.Height(buttonHeight)))
			{
				redCount++;
				
				amIOnTheRedTeam = true;
				
				justConnectedToServer = false;
				
				SpawnRedTeamPlayer();
				
				
			}
		}
			
		
		
	}

How do you expect the other end of the connection to know what button has been clicked if you don’t send any data about it?
I don’t see any RPC calls to update the values between clients and server.

Thanks.
Please be patient, i just learn to setup this things the first time…
I try my best to follow your tips along…

Here are the basic RPCs

I dont know where exactly i have to launch them.
do i have to put the networkview.rpc under the Button action?