Photon Multiplayer Layer Issue

Hey everyone, I have a small issue with setting multiple weapons layer by using for loop. When I run the game and check weapons layer in the inspector its not setting it to anything, I see that for loop is trying to access the weapons layer but sets it to nothing, not even default layer. The layer name is Weapon, it sits at 7th place on layer options. Here is the code that I’m trying to access and set the layer trough:
public class PlayerSetup : Photon.MonoBehaviour {
[SerializeField] GameObject[ ] weaponsLayer;

void Start(){
if(photonView.isMine){
for (int i = 0; i < weaponsLayer.Length; i++) {
weaponsLayer*.layer = 7;*
}
}
}
}
Em I doing something wrong that I don’t know about?
Plus I don’t get any errors either.

Never mind figured it out. There were 2 issues, one was that at layer 7 there was nothing, I was counting layers from drop down and end up with 7 count of layers, but when tried to add new layer, realized that some layers were empty so the real count was at 9. But it still didn’t work, it sets the layer to weapon but nothing happens, so second issue was that actual weapon was a child of empty game object, so I was actually setting the empty game objects layer to Weapon layer instead of actual weapon.
To fix that, had to open empty game object that had weapon in it, then add weapon to GameObject[ ] in the inspector, now the weapons layer is set to Weapon layer.

Rather than using weaponsLayer.layer = 7, I’d recommend doing something like…

void Start()
{
    if(photonView.isMine)
    {
        for(int i = 0; i < weaponsLayer.Length; i++)
        {
            weaponsLayer.layer = LayerMask.NameToLayer("Weapon");
        }
    }
}

… which lets you avoid assigning layer by number directly, which (as you discovered) can lead you astray if layers are initialized differently than you expect. LayerMask.NameToLayer checks all layers for one named “the string you pass in”, and returns an int that corresponds to it.