Photon: interact with objects on both Master and Client

Hi,

I need to create 50 spheres, and then each player can interact with them (they become red when one player touches them). It works fine on the Master, but on the client they all become Red as soon as it appears… How can I solve it?

function OnJoinedRoom(){
poolSpheres = new GameObject[50];

if(PhotonNetwork.isMasterClient){
for (var x = 0; x < poolSpheres.Length; x++){
	poolSpheres[x] = PhotonNetwork.InstantiateSceneObject("Sphere", Vector3(-10,0,0), Quaternion.identity,0, null);
	//poolSpheres[x].GetComponent(sphere).enabled = true;
	poolSpheres[x].transform.position.x = x*2 -4;
}

for (x= 0; x< 5; x++){
	for(var y=0;y<10; y++){
		poolSpheres[y + x*10].transform.position.x = x - 2;
		poolSpheres[y + x*10].transform.position.y = y;
}
}

}
}

Then in another script:

function OnTriggerEnter(other: Collider){
    	if(other.tag == "Cube"){
    		var photonView: PhotonView = PhotonView.Get(this);
    		photonView.RPC("changeColor", PhotonTargets.All);
    		//changeColor();
    	}
    }
    
    
    
    @RPC
    function changeColor(){
    		transform.renderer.material.color = Color.red;
    }
    
    
     function OnPhotonSerializeView(stream: PhotonStream, info:PhotonMessageInfo)
        {
            if (stream.isWriting)
            {
                // We own this player: send the others our data
                stream.SendNext(transform.position);
            }
            else
            {
                // Network player, receive data
                this.transform.position = stream.ReceiveNext();
            }
        }

Any idea how I could make it work?

Yes. In fact you need to synchronize everything with the master. It means you need to check on the master the state of the object, then only send the information to the slave.