Photon variable synchronization

Hello, I’m trying to synchronize a variable which changes whenever one of the players/clients pressed a button.

The problem is that it only works when the First player/Person who creates the room does it, if the second player who joins the created room clicks the buttons it changes the values for him and doesn’t sync on the other player’s pc.

Here’s my code so far:

public float test;

void Update()
    {
        PhotonView photonView = this.photonView;
        photonView.RPC("Test", PhotonTargets.All);
    }

[PunRPC]
    void Test()
    {
        if (Input.GetKeyDown(KeyCode.Alpha0))
        {
            test = 0;
        }
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            test = 1;
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            test = 2;
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            test = 3;
        }
        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            test = 4;
        }
    }

void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            stream.SendNext(test);
        }

        else
        {
            test = (float)stream.ReceiveNext();
        }
    }

Fixed! If you use RPC calls then you no longer need to sync the variables in the OnPhotonSerialieView function.

Updated code:

[PunRPC]
    void Test()
    {
        if (Input.GetKeyDown(KeyCode.Alpha0))
        {
            photonView.RPC("Lel", PhotonTargets.All, 0);
        }
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            photonView.RPC("Lel", PhotonTargets.All, 1);
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            photonView.RPC("Lel", PhotonTargets.All, 2);
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            photonView.RPC("Lel", PhotonTargets.All, 3);
        }
        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            photonView.RPC("Lel", PhotonTargets.All, 4);
        }
    }

    [PunRPC]
    void Lel(int lewl)
    {
        test = lewl;
    }

    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
        }

        else
        {
        }
    }