Multiplayer Source Code Error?

Dear All,

I have recently created a multiplayer system that is not exactly working. I have the spawn script and the controls script. I believe the error is with the spawn script. Could someone please help me identify the error?

#pragma strict
#pragma implicit
#pragma downcast


public var playerPrefab : Transform;


function OnServerInitialized(){
	Spawnplayer();
}

function OnConnectedToServer(){
	Spawnplayer();
}

function Spawnplayer(){
	
	var myNewTrans : Transform = Network.Instantiate(playerPrefab, transform.position, transform.rotation, 0);
	
}




function OnPlayerDisconnected(player: NetworkPlayer) {
	Debug.Log("Clean up after player " + player);
	Network.RemoveRPCs(player);
	Network.DestroyPlayerObjects(player);
}

function OnDisconnectedFromServer(info : NetworkDisconnection) {
	Debug.Log("Clean up a bit after server quit");
	Network.RemoveRPCs(Network.player);
	Network.DestroyPlayerObjects(Network.player);
	
	
	Application.LoadLevel(0);
}

Thanks in advance,
Spongy Zeta Prime

what is the error your getting ?

There was initially an InvalidCastException because of me instantiating the gui but then i realised i didnt need to instantiate the gui, i could just have it onscreen. So no errors as such now. But my thing doesn’t load properly. I think it connects then disconnects immediately, judging by what the log is saying… How do I fix this?

Cheers,
Spongy Zeta Prime

Unless someone has telephatic powers, we don’t know what your talking about.

The spawn script you posted looks ok to me, you will have to add some debug lines and maybe put the debug level to full in the editor so you can see the reason for a disconnect. under Edit → project Settings → Network