how do i send the PunRpc to the specific gameobject?

hi, I have a problem with finding PhotonPlayer with gameobject. I was trying to send the Rpc by

photonView.RPC(“EarnMoney”,EEE.gameObject.GetPhotonView().owner,new object{21});

EEE is the player I wanted to send the rpc, but rpc had sent to another gameobject witch has a same owner. i will be able to solve this if its finding all of them, but its sending to the first one it searches.

how do i code to send the rpc only to a EEE(on the code above) not other gameobjects?

Hi,

please note, that RPCs are always processed on the same object. If you for example use the RPC function of a PhotonView component on Object A, the called function will be processed on the same PhotonView component of the same Object A on every clients’ game.

If you want to use another approach, that works independently from PhotonView components, you can take a look at the RaiseEvent function. It does not require a PhotonView component and messages can be send to specific targets. You can read more about it on the RPCs and RaiseEvent documentation page.

If you just want to handle one int value, you can also take a look at the PunPlayerScores extension. For the local client, you can access the current score by using PhotonNetwork.player.GetScore(). To set or add something to the score, you can use PhotonNetwork.player.SetScore(int value) or PhotonNetwork.player.AddScore(int value). Since this extension uses the Custom Player Properties, the score of each client is automatically synchronized across all clients in the room.