Multiplayer - Player who is not a server run a command to do stuff? how

Hello,

I have a button on a canvas which gets activated when a player enters a sector portal.
The canvas a has a button to continue to next sector and moves all players to new spawn point.
However this only works for the player who is the server.
the player who connects to the other player can activate the button(see it clicking but does nothing)

The code is along the lines of this:

public void SectorButtonClick(){
CmdNextSector();
}

[Cmd]
void CmdNextSector(){
RpcCloseCanvas();
}

[ClientRpc]
void RpcCloseCanvas(){

}

Is this the right process for a the player who connects to the player who is hosting to call the command to close the canvas and activate the logic to move the players.

Works fine if you are hosting the game.

Any suggestions welcome thanks

Daniel

The client will need authority over the object where the command script is in order to call it on the server.
Clients are given authority over their player object when it spawns, you could move the code to a script on that.

ok sounds like a plan, as a rule of thumb should one have the canvas under the player clone that get spawned so they maintain authority locally?

cheers

Perhaps you could do it that way, I’m not sure how happy the main UI canvas is when parented to a moving object though.

Personally I would keep my UI canvas separate and either reference the local player to make command calls, or use a distinct networking object and UNET messages to request actions on the server.

Thanks for the advice, appreciated!