Getting null Exception when I try to spawn player

Here is my code. For some weird reason I am getting a null exception every time I try to spawn my player.

Thank you for the help in advance :slight_smile:

private void SpawnPlayer() {
        Debug.Log ("Spawning Player...");
        Network.Instantiate (Resources.Load ("Resources/SkeletonPlayer"), new Vector3 (6f, 0.6f, 4.5f), Quaternion.identity, 0);
    }


    void OnServerInitialized() {
        Debug.Log ("Server has been initialized");
        SpawnPlayer ();
    }

First you instantiate. Then you spawn the instance of the prefab (not the prefab).
http://docs.unity3d.com/Manual/UNetSpawning.html

GameObject tree = (GameObject)Instantiate(treePrefab, transform.position, transform.rotation); NetworkServer.Spawn(tree);

thanks so much!!! that was perfect!!! Now I am running into another issue though. I try to instantiate my prefab but it tells be there is no connection to the server. But the this is I run the code below and it gets through my nests if statements every time. The most odd part is that everything seems to work until I get to my instantiate.

public void SetupServer()
    {
        NetworkServer.Listen(4444);
        isAtStartup = false;
        int x = 0;
        while (x == 0)
        {
            if (NetworkServer.active)
            {
                Debug.Log("Server Connected");
                x = 1;
            }
        }
    }

public void SetupClient()
    {
        myClient = new NetworkClient();
        myClient.RegisterHandler(MsgType.Connect, OnConnected);
        myClient.Connect("127.0.0.1", 4444);
        myClient.RegisterHandler(MsgType.Connect, OnConnected);
        ClientScene.RegisterPrefab(playerPrefab);

        isAtStartup = false;       
    }

    // Create a local client and connect to the local server
    public void SetupLocalClient()
    {
        myClient = ClientScene.ConnectLocalServer();
        myClient.RegisterHandler(MsgType.Connect, OnConnected);
        isAtStartup = false;
    }

    // client function
    public void OnConnected(NetworkMessage netMsg)
    {
        Debug.Log("Connected to server");
        int x = 0;
        while (x == 0)
        {
            if (myClient.isConnected)
            {
                Network.Instantiate(playerPrefab, new Vector3(6f, 0.6f, 4.5f), Quaternion.identity, 0);
                x = 1;
            }
        }
    }