Creating an RPC "Unexpected symbol '['"

Hi, I am working on a script to tell a server instance of the game what player number to spawn in when a new player joins the game. Before I added an RPC to make the game send the information to the server, it worked fine. Now that I have the RPC, it gives me the error message “error CS1525: Unexpected symbol ‘{’” on the first RPC. My code is:(I have made the first RPC bold)

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;
	
	
	//Used to determine which team the player is on.
	
	public bool amIPlayer1 = false;
	
	public bool amIPlayer2 = false;

	public bool amIPlayer3 = false;

	public bool amIPlayer4 = false;
	
	//Used to define the JoinTeamWindow.
	
	private Rect joinTeamRect;
	
	public string joinTeamWindowTitle = "Player 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 TPlayer1;
	
	public Transform TPlayer2;

	public Transform TPlayer3;

	public Transform TPlayer4;

	
	private int IPlayer1 = 0;
	
	private int IPlayer2 = 1;
	
	private int IPlayer3 = 2;

	private int IPlayer4 = 3;
	//Used to capture spawn points.
	
	private GameObject[] SpawnPlayer1;
	
	private GameObject[] SpawnPlayer2;

	private GameObject[] SpawnPlayer3;

	private GameObject[] SpawnPlayer4;

	private int JoinNo = 1;

	public bool spawnedPlayer1 = false;
	public bool spawnedPlayer2 = false;
	public bool spawnedPlayer3 = false;
	public bool spawnedPlayer4 = false;
	
	
	//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 (justConnectedToServer == true) {

			if (GUILayout.Button ("Spawn", GUILayout.Height (buttonHeight))) {

				if(spawnedPlayer1 == false){

				amIPlayer1 = true;
				
				justConnectedToServer = false;
				
				spawnedPlayer1 = true;

				VSpawnPlayer1 ();
				}

				if(Network.isServer){
					networkView.RPC ("Player1", RPCMode.All, amIPlayer1);
				}
				if(Network.isClient){
					Player1(amIPlayer1);
				}


				else if(spawnedPlayer2 == false){
					
					amIPlayer2 = true;
					
					justConnectedToServer = false;
					
					spawnedPlayer2 = true;
					
					VSpawnPlayer2 ();
				}

				if(Network.isServer){
					networkView.RPC ("Player2", RPCMode.All, amIPlayer2);
				}
				if(Network.isClient){
					Player2(amIPlayer2);
				}

				else if(spawnedPlayer3 == false){
					
					amIPlayer3 = true;
					
					justConnectedToServer = false;
					
					spawnedPlayer3 = true;
					
					VSpawnPlayer3 ();
				}
				if(Network.isServer){
					networkView.RPC ("Player3", RPCMode.All, amIPlayer3);
				}
				if(Network.isClient){
					Player3(amIPlayer3);
				}

				else if(spawnedPlayer4 == false){
					
					amIPlayer4 = true;
					
					justConnectedToServer = false;
					
					spawnedPlayer4 = true;
					
					VSpawnPlayer4 ();
				}
				if(Network.isServer){
					networkView.RPC ("Player4", RPCMode.All, amIPlayer4);
				}
				if(Network.isClient){
					Player4(amIPlayer4);
				}




			}

		
		}

		**[RPC] void Player1(bool amIPlayer1){
			amIPlayer1 = amIPlayer1;**
		}

		[RPC]
		void Player2(bool amIPlayer2){
			amIPlayer2 = amIPlayer2;
		}

		[RPC]
		void Player3(bool amIPlayer3){
			amIPlayer3 = amIPlayer3;
		}

		[RPC]
		void Player4(bool amIPlayer4){
			amIPlayer4 = amIPlayer4;
		}


				//If the player clicks on the Join Red Team button then
				//assign them to the red team and spawn them into the game.
	//			if (justConnectedToServer == true) {
	//					if (GUILayout.Button ("Player 1", GUILayout.Height (buttonHeight))) {
	//							amIPlayer1 = true;
	//	
	//							justConnectedToServer = false;
	//	
	//							VSpawnPlayer1 ();
	//					}
	//
	//
	//					//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 ("Player 2", GUILayout.Height (buttonHeight))) {
	//							amIPlayer2 = true;
	//	
	//							justConnectedToServer = false;
	//	
	//							VSpawnPlayer2 ();
	//					}
	//
	//					if (GUILayout.Button ("Player 3", GUILayout.Height (buttonHeight))) {
	//							amIPlayer3 = true;
	//	
	//							justConnectedToServer = false;
	//	
	//							VSpawnPlayer3 ();
	//					}
	//
		//				if (GUILayout.Button ("Player 4", GUILayout.Height (buttonHeight))) {
		//						amIPlayer4 = true;
		//
		//						justConnectedToServer = false;
		//
				//				VSpawnPlayer4 ();
				//		}
				//}
		//}

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);
	}
}

		






	
	
	void VSpawnPlayer1 ()
	{
		//Find all red spawn points and place a reference to them in the array
		//redSpawnPoints.
		
		SpawnPlayer1 = GameObject.FindGameObjectsWithTag("SpawnPlayer1");
		
		
		//Randomly select one of those spawn points.
		
		GameObject randomRedSpawn = SpawnPlayer1[Random.Range(0, SpawnPlayer1.Length)];
		
		
		//Instantiate the player at the randomly selected spawn point.
		
		Network.Instantiate(TPlayer1, randomRedSpawn.transform.position,
		                    randomRedSpawn.transform.rotation, IPlayer1);
	}
	
	

	void VSpawnPlayer2 ()
	{
		//Find all red spawn points and place a reference to them in the array
		//redSpawnPoints.
		
		SpawnPlayer2 = GameObject.FindGameObjectsWithTag("SpawnPlayer2");
		
		
		//Randomly select one of those spawn points.
		
		GameObject randomRedSpawn = SpawnPlayer2[Random.Range(0, SpawnPlayer2.Length)];
		
		
		//Instantiate the player at the randomly selected spawn point.
		
		Network.Instantiate(TPlayer2, randomRedSpawn.transform.position,
		                    randomRedSpawn.transform.rotation, IPlayer2);
	}

	void VSpawnPlayer3 ()
	{
		//Find all red spawn points and place a reference to them in the array
		//redSpawnPoints.
		
		SpawnPlayer3 = GameObject.FindGameObjectsWithTag("SpawnPlayer3");
		
		
		//Randomly select one of those spawn points.
		
		GameObject randomRedSpawn = SpawnPlayer3[Random.Range(0, SpawnPlayer3.Length)];
		
		
		//Instantiate the player at the randomly selected spawn point.
		
		Network.Instantiate(TPlayer3, randomRedSpawn.transform.position,
		                    randomRedSpawn.transform.rotation, IPlayer3);
	}

	void VSpawnPlayer4 ()
	{
		//Find all red spawn points and place a reference to them in the array
		//redSpawnPoints.
		
		SpawnPlayer4 = GameObject.FindGameObjectsWithTag("SpawnPlayer4");
		
		
		//Randomly select one of those spawn points.
		
		GameObject randomRedSpawn = SpawnPlayer4[Random.Range(0, SpawnPlayer4.Length)];
		
		
		//Instantiate the player at the randomly selected spawn point.
		
		Network.Instantiate(TPlayer4, randomRedSpawn.transform.position,
		                    randomRedSpawn.transform.rotation, IPlayer4);
	}
	
}

Thanks for your help!

looks like you’re missing a closing brace at the end of JoinTeamWindow()

it’s a good idea to make sure your opening and closing braces match up in the editor so it’s easier to spot rookie mistakes like that. yeah, i called you a rookie :wink:

if you’ve got a block of code that you want to comment out, put /* at the start and */ at the end - it’s way easier than adding a // to every line!