Help! Error: NullReferenceException: Object reference not set to an instance of an object IsMine.Start () (at Assets/Scripts/IsMine.cs:15)

Help me! Error:

NullReferenceException: Object reference not set to an instance of an object IsMine.Start () (at Assets/Scripts/IsMine.cs:15)

Line content:if (!_photonView.IsMine)
if (!_photonView.IsMine):

using UnityEngine;
using Photon.Pun;

public class IsMine : MonoBehaviour
{

    [SerializeField] private PlayerMovement _playerMovement;
    [SerializeField] private MouseLook _mouseLook;
    [SerializeField] private GameObject _camera;
    [SerializeField] private PhotonView _photonView;
    [SerializeField] private GameObject _playerModel;

    void Start()
    {
        if (!_photonView.IsMine)
        {
            _playerMovement.enabled = false;
            _mouseLook.enabled = false;
            _camera.SetActive(false);
            _playerModel.SetActive(true);
        }
    }

}

Make sure that the bool IsMine is public in the PhotonView Script, otherwise the IsMine Script can’t access it.

Recommendation: Use different variable names for different types of scripts.

I would also check if _photonView is set in the inspector. You can either see that in the inspector, or by adding a Debug.Assert() near the beginning of your Start() method:

Debug.Assert(_photonView != null, “_photonView is null”); and watch for your error string in the console.

Also, you can place a breakpoint on your “if” test, so that execution stops at the breakpoint, and you easily inspect the values of your variables and fields by hovering your mouse over them.