Null Refrence Exception in Argument

I have hit this wall while trying to solve the error I keep getting. It most likely will be something very simple. I am currently connecting to an uLink authoritative server from a main menu scene. The server then tells the main menu what map to load. This all works but when I try to instantiate the character I keep getting two errors (the error occurs when SpawnMyPlayer is called), a null exception and warning that the rpc call couldn’t be completed.

  • System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.ArgumentNullException: Argument cannot be null.
    -Failed to invoke Method Spawner:ClickedTheDeployButton with 3 parameters: a, 1234, Sender: Player Client (1), timestamp: 9.731

Here is my code that I am currently using.
Level/ Scene Load (Called From Server)

RPC]
public void MapLoad(string MapName, uLink.NetworkPlayer player){
Debug.Log (MapName);
if (MapName == "GrandBazar") {
Application.LoadLevel ("Map Grand Bazar Client");
}
}

Spawn Screen Code (RPC From Client To Server)

public void spawnRPCCall(){

string location = "a";



string PlayerID = "1234";

transform.root.gameObject.GetComponent().RPC("ClickedTheDeployButton", uLink.RPCMode.Server,location,PlayerID);

}

Spawn Code (Located on the Server)

[RPC]
public void ClickedTheDeployButton(string location, string playerID, uLink.NetworkMessageInfo info){
uLink.NetworkPlayer player = info.networkView.owner;
SpawnMyPlayer (player, location, playerID); //This Line Generates The Error

}

void SpawnMyPlayer(uLink.NetworkPlayer playertospawn, string location, string passedPlayerID){
//Get The Random Spawn Location
GetRandomSpawnPoint (location);

//Instantiate The Player
GameObject instantiatedPlayer;
instantiatedPlayer = uLink.Network.Instantiate(playertospawn, proxyPrefab, ownerPrefab, creatorPrefab, selectedSpawnLocation.transform.position, selectedSpawnLocation.transform.rotation, 0, dataspilt);






}

Any help would be greatly appreciated!

I’m thinking you forgot the last parameter of your ClickedTheDeployButton method.

Your method signature has three parameters:

public void ClickedTheDeployButton(string location, string playerID, uLink.NetworkMessageInfo info)

But when you call the method (with the RPC call) you use just two parameters:

transform.root.gameObject.GetComponent().RPC("ClickedTheDeployButton", uLink.RPCMode.Server,location,PlayerID);

You forgot the info parameter.