Trying to send command for object without authority.

I have an empty GameObject with scripts, i added networkIdentity to it.

I haves UI button on the scene that triggers “Btn_Button ()”.

I get the “Trying to send command for object without authority”, line 16, when i click button on client. I just do not get this work and would like to get some help from someone nice.

This is the script:

using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
using UnityEngine.UI;

public class UI_Menu1 : NetworkBehaviour {

    public Animator anim_Menu;
    public Button btn_OpenMenu;
    private bool yourBool = false;

    [SyncVar(hook = "UI_DoMenu")] private bool _myBool = false;

    void UI_DoMenu(bool value) {

        Cmd_Print ();

 }


    public void Btn_Button () {
        if (yourBool) {
            yourBool = false;
        } else {
            yourBool = true;
        }

        _myBool = yourBool;
    }

    [Command]
    void Cmd_Print() {
        print ("HIT");
    }

}

I thought I already answered you but anyway I would take different approach. This problem occurs because this script doesn’t check if you are localplayer with authority (you have two players and this script triggers on both players instead of local one who started it). You can try two things: (Im not sure of first one)

void UI_DoMenu(bool value) {
   if( ! isLocalPlayer) return;

   Cmd_Print();
}

And second one which I use is that I disable component (UI_Menu1) in the playerPrefab and enable it just for LocalPlayer like this:

public override void OnStartLocalPlayer()
{
   this.enabled = true;
}

@Chom1czek thanks for you help. Unfortunately it does not trigger the Cmd_Print! I guess the reason i that it is not local.

The script is located on an empty GameObject, with NetworkIdentity, but not registered as a prefab. Maybe that is the problem.