Problems with Network.Instantiate

Hello,

I have been following a tutorial for a multiplayer game and have hit a brick wall. I have the following script on a GameObject with the prefabs connected and what not but the game won’t spawn my player. There is nothing in the log, no errors, no players in the scene, it just won’t work. Script:

var playerPrefab:GameObject;
var spawnObject:Transform;
var gameName:String = "slothworks1";

private var refreshing:boolean;
private var hostData:HostData[];

private var buttonX:float;
private var buttonY:float;
private var buttonW:float;
private var buttonH:float;

function Start(){
	buttonX = Screen.width * 0.05;
	buttonY = Screen.width * 0.05;
	buttonW = Screen.width * 0.1;
	buttonH = Screen.width * 0.1;
}

function startServer(){
	Network.InitializeServer(32, 25001, !Network.HavePublicAddress);
	MasterServer.RegisterHost(gameName, "Tutorial Game Name", "This is a tutorial game");
}

function refreshHostList(){
	MasterServer.RequestHostList(gameName);
	refreshing = true;
}

function Update(){
	if(refreshing){
		if(MasterServer.PollHostList().Length > 0){
			refreshing = false;
			Debug.Log(MasterServer.PollHostList().Length);
			hostData = MasterServer.PollHostList();
		}
	}
}

function spawnPlayer(){
	Network.Instantiate(playerPrefab, spawnObject.position, Quaternion.identity, 0);
}

function OnServerInitialized(){
	Debug.Log("Server Initialized");
}

function OnConnectedToServer(){
	spawnPlayer();
}

function OnMasterServerEvent(mse:MasterServerEvent){
	if(mse == MasterServerEvent.RegistrationSucceeded){
		Debug.Log("Registered Server");	
	}
}

function OnGUI(){
	if(!Network.isClient && !Network.isServer){
		if(GUI.Button(Rect(buttonX, buttonY, buttonW, buttonH), "Start Server")){
			Debug.Log("Starting Server");
			startServer();
		}
		
		if(GUI.Button(Rect(buttonX, buttonY * 1.2 + buttonH, buttonW, buttonH), "Refresh Hosts")){
			Debug.Log("Hosts Refreshing");
			refreshHostList();
		}
		
		if(hostData){
			for(var i:int = 0; i<hostData.length; i++){
				if(GUI.Button(Rect(buttonX * 1.5 + buttonW, buttonY*1.2 + (buttonH * i), buttonW*3, buttonH*0.5), hostData*.gameName)){*

_ Network.Connect(hostData*);_
_
}_
_
}_
_
} _
_
}_
_
}*_

There may be a few causes of this, you may be making the client call network.Instantiate but then calling something else at the same time, maybe loading a scene which may cause issues, another thing that may be causing it is if you dont have application.runinbackground on, this may be causing issues where the client sends the call to the server, it cant recieve it because its minimized, and then it might not spawn.