PUN Client is not the MasterClient in the room (Instantiate)

Failed to InstantiateSceneObject prefab. AirPlane, Client is not the MasterClient in the room

image and script below:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FlareAirDrop : MonoBehaviour {

    public GameObject AirPlane;
    public GameObject AirDrop;
    public float speed;
    private bool suport = false;
    public PhotonView photonView;
    private bool suport2 = false;

    [PunRPC]
    public void Airplanespawn (){

        AirPlane = PhotonNetwork.InstantiateSceneObject ("AirPlane", new Vector3 (Random.Range (-1000, 1000), 230, -100), Quaternion.identity, 0, null) as GameObject;

        Vector3 relativePos = AirPlane.transform.position - transform.position;
        Quaternion rotation = Quaternion.LookRotation(relativePos);
        AirPlane.transform.rotation = rotation;
    }

    [PunRPC]
    public void airdropspawn (){

        AirDrop = PhotonNetwork.InstantiateSceneObject ("AirDrop", new Vector3 (AirPlane.transform.position.x, AirPlane.transform.position.y - 10, AirPlane.transform.position.z), Quaternion.identity, 0, null) as GameObject;

    }

    void Update () {

        if (Input.GetKeyDown ("e")) {

            if (photonView.isMine) {
                gameObject.GetComponent<PhotonView> ().RPC ("Airplanespawn", PhotonTargets.All, null);
                suport2 = true;
            }
        }

        float step = speed * Time.deltaTime;

        if (suport == false && suport2 == true) {

            AirPlane.transform.position = Vector3.MoveTowards (AirPlane.transform.position, new Vector3 (transform.position.x, 230, transform.position.z), step);
       
        } 

        if (suport == true) {
           
            AirPlane.transform.Translate (0, 0.2f, -step);

        }

        if (AirPlane.transform.position.z >= transform.position.z && suport == false) {

                suport = true;
                suport2 = true;
                Debug.LogAssertionFormat ("AirDroped");
                photonView.RPC ("airdropspawn", PhotonTargets.All, null);

            }
        }
    }


Well, the error says it all: Only the Master Client of a room can instantiate scene objects.
You can place networked objects in the scene and the Master Client can use InstantiateSceneObject at runtime.
In all other cases, use PhotonNetwork.Instantiate for networked objects.

I tried to put only Instantiate, but it only works for the player who owns the room (masteclient) and not the other player that comes in after, how do I do for everyone? This has been my problem, a non-masterclient player is not able to instantiate “AirPlane” for all players…

I assume you’re loading a scene and don’t stop running the network message queue while doing so. A typical issue is that instantiated objects get desctroyed when loading a new scene, so they are never visible.

Code the tutorial again. Read this:

So how should I solve this? My connection script below, is there something wrong?

using System.Collections.Generic;
using UnityEngine;

public class mt_Connection : Photon.MonoBehaviour
{
    string PlayerName = "Player";
    string DefaultPlayerName = "Player";

    static mt_Lobby m_Lobby = null;
    static mt_Lobby Lobby
    {
        get
        {
            if (m_Lobby == null)
                m_Lobby = FindObjectOfType<mt_Lobby>();
            return m_Lobby;
        }
    }

    List<PhotonPlayer> m_PlayerList = new List<PhotonPlayer>();
    public List<PhotonPlayer> PlayerList
    {
        get
        {
            m_PlayerList.Clear();
            m_PlayerList.TrimExcess();
            foreach (PhotonPlayer players in PhotonNetwork.playerList)
            {
                m_PlayerList.Add(players);
            }
            return m_PlayerList;
        }
    }

    void Awake(){

        PhotonNetwork.automaticallySyncScene = true;

    }

    public void JoinServer(bool create, bool random)
    {
        if (create && !random) CreateRoom();
        else if (!create && !random) JoinRoom();
        else if (!create && random) JoinRandom();

    }

    void CreateRoom()
    {
      
        RoomInfo[] rooms = PhotonNetwork.GetRoomList();
        string roomName = Lobby.RoomName;
        for (int i = 0; i < rooms.Length; i++)
        {
            if (roomName.Equals(rooms[i].Name))
            {
                roomName += "(" + PhotonNetwork.GetRoomList().Length + 1 + ")";
            }
        }
        Debug.Log("trying to create room: " + roomName);

        ExitGames.Client.Photon.Hashtable customPropertiesToSet = new ExitGames.Client.Photon.Hashtable();
        customPropertiesToSet.Add("MapName", Lobby.MapName);
        customPropertiesToSet.Add("GameMode", Lobby.GameMode);
        customPropertiesToSet.Add("MapImage", Lobby.SelectedMap);
        customPropertiesToSet.Add("GameLength", Lobby.GameLength);
        customPropertiesToSet.Add("Password", Lobby.Password);
        //customPropertiesToSet.Add("Team", Lobby.Team);

        string[] customProperties = new string[5];
        customProperties[0] = "MapName";
        customProperties[1] = "GameMode";
        customProperties[2] = "MapImage";
        customProperties[3] = "GameLength";
        customProperties[4] = "Password";
        PhotonNetwork.CreateRoom(roomName, new RoomOptions() { MaxPlayers = (byte)Lobby.MaxPlayers, IsVisible = true, IsOpen = true, CustomRoomProperties = customPropertiesToSet, CleanupCacheOnLeave = true, CustomRoomPropertiesForLobby = customProperties }, null);

    }

    bool JoinRoom()
    {
        Debug.Log("trying to join room: " + Lobby.RoomName);
        return PhotonNetwork.JoinRoom(Lobby.RoomName);

  
    }

    void JoinRandom()
    {
        Debug.Log("trying to join a random room");
        PhotonNetwork.JoinRandomRoom();

    }

    public void Reconnect()
    {
        if (PhotonNetwork.connectionStateDetailed != ClientState.Disconnected && PhotonNetwork.connectionStateDetailed != ClientState.PeerCreated)
        {
            PhotonNetwork.Disconnect();
        }

        PhotonNetwork.ConnectUsingSettings("0.1");
    }

    void OnJoinedLobby()
    {
        Lobby.currentWindow = mt_Lobby.CURRENTWINDOW.MAIN;
        Lobby.InvokeRepeating("ServerList", 1, Lobby.ServerListRefresh);

        if (PlayerName == DefaultPlayerName && PlayerPrefs.GetString("PlayerName") != "") PlayerName = PlayerPrefs.GetString("PlayerName");
        PhotonNetwork.playerName = PlayerName;
        Debug.Log("PlayerName set to " + PhotonNetwork.playerName);
    }

    void OnLeftLobby()
    {

    }
    void OnReceivedRoomListUpdate()
    {
        Debug.Log("rooms updated: " + PhotonNetwork.GetRoomList().Length);
        Lobby.MessageText(null, Color.red, 0);
    }

    void OnJoinedRoom()
    {
        Lobby.currentWindow = mt_Lobby.CURRENTWINDOW.NONE;
        Debug.Log("Joined Room");

        List<PhotonPlayer> playerList = new List<PhotonPlayer>();
        playerList.Clear();
        playerList = PlayerList;
        for (int p = 0; p < playerList.Count; p++)
        {
            Debug.Log("Players connected: " + playerList[p].NickName);
            if (playerList[p] != PhotonNetwork.player)
            {
                if (playerList[p].NickName == PhotonNetwork.playerName)
                {
                    PhotonNetwork.playerName = PhotonNetwork.playerName + "(" + 1 + ")";
                }
            }
        }

        PhotonNetwork.LeaveLobby();
        PhotonNetwork.LoadLevel (Lobby.RoomName);

    }

    void OnFailedToConnectToPhoton(DisconnectCause er)
    {
        Debug.LogWarning("mt_Connection: Failed To Connect To Cloud: " + er);
        Lobby.MessageText("Waiting for Internet Connection...", Color.red, 999, TextAnchor.UpperLeft);
        InvokeRepeating("Reconnect", 3.5f, 3.5f);
    }

    void OnConnectionFail(DisconnectCause er)
    {
        Debug.LogWarning("mt_Connection: Connection Failed: " + er);
        Lobby.MessageText("Waiting for Internet Connection...", Color.red, 999, TextAnchor.UpperLeft);
        InvokeRepeating("Reconnect", 3.5f, 3.5f);
    }

    void OnConnectedToMaster()
    {
        Debug.Log("Connected to Master");
        Lobby.MessageText("Connected to Master", Color.red, 3, TextAnchor.UpperLeft);
        CancelInvoke("Reconnect");
    }

    void OnPhotonRandomJoinFailed()
    {
        Debug.Log("mt_Connection: No random room available, so we create one.");
        CreateRoom();
    }
}


(https://uploaddeimagens.com.br/images/001/000/470/full/esse.png?1500417660)

I tried to use this, it seemed Favorable but it did not result in any improvement the same thing continues.

    PhotonNetwork.LeaveLobby();
    PhotonNetwork.LoadLevel (Lobby.RoomName);
    PhotonNetwork.isMessageQueueRunning = false;

(Script Above)

help =/

I tried this:

In my airplane prefab on Resources folder

void OnPhotonInstantiate(PhotonMessageInfo info)
    {
        FlareAirDrop myObject = GameObject.FindObjectOfType<FlareAirDrop>();
        myObject.AirPlane = gameObject;
    }

but nothing again =/