Why do some buffered RPCs show up sometimes for new players?

For my game, players connect directly to a room where they see three buttons. Each player clicks on the button that represents the character they want to play as. When a player clicks on a button, it disables that button for the other players so no one can play as the same character.

This works fine if all players join the room before anyone clicks a button. However, if two players are in the room and each select a character, then the third player joins, only one of the button is disabled and there is an error
"NullReferenceException: Object reference not set to an instance of an object
DisableButtonFOrAllPlayers.RPC_DisableButton () (at Assets/Tree Axe Fire/Scripts/DisableButtonFOrAllPlayers.cs:25)"

When a button is clicked, this method is called:
public void PyroSelected()
    {
        characterType = CharacterType.Pyro;
        SetSelectedColor(pyroButton);
        pyroButton.GetComponent<DisableButtonFOrAllPlayers>().CallDisableButtonRPC();
        planterButton.interactable = false;
        chopperButton.interactable = false;
        CheckIfAllPlayersReady();
    }

The above code is on an empty Game Object with a PhotonView. However, it calls a script attached directly to the button (also with a PhotonView) that needs to be disabled:
public class DisableButtonFOrAllPlayers : MonoBehaviourPun
{
    Button button;

    private void Start()
    {
        button = this.GetComponent<Button>();
    }

    public void CallDisableButtonRPC()
    {
        photonView.RPC("RPC_DisableButton", RpcTarget.AllBuffered);
    }

    [PunRPC]
    void RPC_DisableButton()
    {
        button.interactable = false;
    }
}

The target is AllBuffered but in practice, the first click is lost if all three players are not connected. However, the second button click seems to get sent to the new player.

Comments

This discussion has been closed.