Call Functions On Player From Canvas Elements In a Multiplayer Game

So I was originally using the singleton idea to call functions on the player but then I quickly realized that that wouldn’t work in an online multiplayer setting, so how do I go about trying to call functions from buttons and sliders on the canvas?

One way might be to have a singleton GameManager class cache a reference to the local player’s gameObject (I’m assuming you only want the button to affect the local player), then use that reference in whatever class is handling your UI methods.

public void OnButtonClick()
{
        GameManager.Instance.LocalPlayer.GetComponent<SomeClass>().DoSomething();
}