Sync data to different players

Hello! I have buttons in my masterclient an if the host presses that button, other players will see what button the host pressed. I tried PunRPC but it’s not working. Does anyone know what to do? here is a partial of the script

I have this button

public void GameObjectValue()
    {
   
            gameObjectVote = true; //bool

        button1.interactable = false;
       button2.interactable = false;
      
    }

and then this PunRPC

 [PunRPC]
    void SendGameObjectValue()
    {
        gameObjectValue.text = "Game1";
        gameObjectValue.SetActive(true);
    }

and then I set it in update to update the data everytime a new player enters the room

 void Update()
    {
       

        if (button1.interactable == false && button2.interactable == false)
        {
            photonView.RPC("SendGameObjectValue", RpcTarget.Others);
        }

    }

man PUN really should rework their RPC tutorial… i see so many people running into this same issue…

anyway…: First lets try to understand what an RPC is. It is a function that player A and B know of and that one player can call at the other players game instance.

So A can call SendGameObjectValue to be executed at player B. The only information that you currently send however is that this function is to be executed. You do not transmit any other data yet.

To change that you have to add arguments to that function. Lets assume you have a function

void  SendGameObjectValue(bool value1, bool value2)
{
      gameObject1.SetActive(value1);
      gameObject2.SetActive(value2);
}

then that would be able to receive 2 boolean values and set those values to the active state of the local objects gameObject1 and gameObject2

Then you only have to add actual values to the RPC call:

photonView.RPC("SendGameObjectValue", RpcTarget.Others, true, false);

This will then call SendGameObjectValue at all other players where this photonView is existent with the arguments value1= true and value2 = false