Need help fixing my code for the unity multiplayer tutorial...

i have been following the simple multiplayer tutorial and i have hit a problem i am not sure how to fix.

Assets/PlayerHealth.cs(17,18): error CS0029: Cannot implicitly convert type `UnityEngine.Networking.NetworkStartPosition' to `UnityEngine.Networking.NetworkStartPosition[]'

This error came up, and i’m not sure why, here is the code it is referring to.

using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;

public class PlayerHealth : NetworkBehaviour {

    public const int maxHealth = 100;
    [SyncVar (hook = "OnChangeHealth" )]public int currentHealth = maxHealth;
    public RectTransform healthbar;
    public AudioSource die;

    private NetworkStartPosition[] spawnPoints;

    void Start(){
        if (isLocalPlayer) {
            spawnPoints = FindObjectOfType<NetworkStartPosition>();
        }
    }

    public void TakeDamage(int amount){
        if (!isServer) {
            return;
        }
        currentHealth -= amount;
        if (currentHealth <= 0) {
            die.Play();
            currentHealth = maxHealth;
            RpcRespawn ();
        }



    }
    void OnChangeHealth(int health){
        healthbar.sizeDelta = new Vector2 (health*2, healthbar.sizeDelta.y);
    }

    [ClientRpc]
    void RpcRespawn(){
        if (isLocalPlayer)
        {
            Vector3 spawnPoint = Vector3.zero;

            if (spawnPoints != null && spawnPoints.Length >0)
            {
                spawnPoint = spawnPoints [Random.Range (0, spawnPoints.Length)].transform.position;
            }
            transform.position = spawnPoint;   
               
               
        }
       
    }
}

It’s because you’re asking for a single object FindObject (<- singular) to populate an array (plural).

wow… thanks… I’m surprised i missed that!

It happens. :slight_smile: You’re welcome.