Gameobject disappears when the masterclient exits

Options
public override void OnJoinedRoom()
    {
       
        if (PhotonNetwork.IsMasterClient)
        {
            spawnerEnemy.instance.runSpawn();
        }
    }
When entering the room, masterclient will run the spawn function below
public void runSpawn()
    {
        StartCoroutine(spawn());
    }
    
     IEnumerator spawn()
     {
            while (true)
            {
                PhotonNetwork.Instantiate(enemy.name, spawnerpoint[Random.RandomRange(0, 6)].transform.position, enemy.transform.rotation);
                yield return new WaitForSeconds(2);
            }
      }
When the masterclient exits the room, the masterclient will switch to another client and continue running the spawn function. Some object instances from the previous masterclient will disappear, I don't understand why.

This is the video I test on youtube https://youtu.be/OWagz7orDqU

Comments