Photon connections problems caused by a script?

This is the code that is creating the problem (more specifically it’s the code inside the “foreach”):

    void Start()
    {
        photonView = GetComponent<PhotonView>();
        if (photonView.IsMine)
        {
            allGameObjects = FindObjectsOfType(typeof(GameObject));
            foreach (GameObject objct in allGameObjects)
            {
                if (objct.tag != LayerMask.LayerToName(gameObject.layer) && objct.tag != "IgnoreDeletion")
                {
                    Destroy(objct);
                }
            }
        }
    }

The problem is that after I build the game and run it twice the second player can’t connect to the first player that created the room and gets a “no such room exists”. That is the case, but I tried the same built game a few times and sometimes it works; I say this because I assume it’s something that has to do with performance or not allowing enough time or something like that, hopefully it can help you know what the exact problem is.

I mean that code probably destroys almost all the objects in the game, if not all of them…
What are you trying to do?
First off, you shouldn’t destroy objects unless you created them in multiplayer.
Second, try using GameObject.FindObjectsWithTag(“tag”) - your logic is wide open and it reads like it will destroy almost everything… which I doubt is your intention.

My understanding of Photon is that each client loads the scene as if it was single player. Objects with photon views are synced (depends on which parts of that object you’re syncing also, i.e., transforms). If player two joins the room, that doesn’t mean that player one is going to see new items pop up and duplicated. Unless both clients are calling PhotonNetwork.Instantiate or RPC instantiations. Something is going confusingly wrong if when player two joins, his world is being duplicated on top of player ones world.
Use PhotonNetwork.Destroy on photonviews if you want both clients to destroy the same object. If you do regular Destroy, only the player who called it will show it as destroyed.