'Making Multiple playered Multiplayer Card Game With Mirror

I am trying to built a multiplayer card game with max 4 players and I am very new to Multiplayer Games. Idea is there is a "Deal Card" button, when a player clicks on it 14 cards should be dealt to his/her hand.(I am open to suggestions about dealing cards to each player's hand with one click only). Anyway i wrote the codes below. Basically, when server starts in generates cards and add them to deck (List(Card)). Button should take 14 cards from deck and instantiate it according to its info and card Images. When 4 players connected, Each player should get 14 cards to their hands and game starts. So in below code, when host player clicks 14 cards are taken from deck and instantiated as per their infos and card Images and set parent to right place but when other players click i get this error;

"Trying to send command for object without authority. PlayerManager.CmdShowCards UnityEngine.Logger:Log(LogType, Object)"

I tried a few ways to remove this error, i removed but still other players can't get their cards (Button clicks but doesn't do anything.)

I am using parelsync to check game.

So any suggestions to make it right or any other way to make what i mentioned??

Here below my codes;

Deal Card Class (Attached to button);

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;

public class DealCards : NetworkBehaviour
{
    public PlayerManager playerManager;

    public void OnClick()
    {
         NetworkIdentity netWorkIdentity = NetworkClient.connection.identity;
         playerManager = netWorkIdentity.GetComponent<PlayerManager>();
         playerManager.CmdGenerateCardLists();
    }
} 

And Here Below PlayerManager Class;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
using System.Linq;
using UnityEngine.UI;

public class PlayerManager : NetworkBehaviour
{
    public GameObject gameBoard;
    public GameObject deckPlace;
    public GameObject okeyPlace;
    public GameObject playerArea;

    public List<GameObject> deck = new List<GameObject>();
    public List<Card> hand = new List<Card>();
    public List<Sprite> cardImages = new List<Sprite>();
    public GameObject cardPrefab;

    [Client]
    public override void OnStartClient()
    {
        base.OnStartClient();

        playerArea = GameObject.Find("PlayerArea");
        gameBoard = GameObject.Find("GameBoard");
        deckPlace = GameObject.Find("Deck");
        okeyPlace = GameObject.Find("OkeyPlace");
    }

    [Server]

    public override void OnStartServer()
    {
        //Generating Cards
        #region Generating FirstDeckOfCards

        List<Card> jokers = new List<Card>();

        Card joker = new Card()
        {
            realValue = 1,
            name = "Joker",
            suit = Card.Suit.joker,
            imgSuit = Card.ImageSuit.jokerImg,
            subValue = 0,
            backFace = Card.Color.cream,
            isJoker = true
        };


        List<Card> clubsSeries = new List<Card>();

        //Clubs Series
        Card aceOfClubs = new Card()
        {
            realValue = 1,
            name = "Clubs",
            suit = Card.Suit.clubs,
            imgSuit = Card.ImageSuit.clubsImg,
            subValue = 0,
            backFace = Card.Color.cream
        };

           And So on...

        #region Joker Cards Are Added To Joker List

        jokers.Add(joker);

        #endregion Joker Cards Are Added To Joker List
        #region Joker2 Cards Are Added To Joker List

        jokers2.Add(joker2);

        #endregion Joker2 Cards Are Added To Joker List

        //Clubs Cards Are Added To ClubsSeries List
        #region Clubs Cards Are Added To ClubsSeries List

        clubsSeries.Add(aceOfClubs);
        clubsSeries.Add(twoOfClubs);
        clubsSeries.Add(threeOfClubs);
        clubsSeries.Add(fourOfClubs);
        clubsSeries.Add(fiveOfClubs);
        clubsSeries.Add(sixOfClubs);
        clubsSeries.Add(sevenOfClubs);
        clubsSeries.Add(eightOfClubs);
        clubsSeries.Add(nineOfClubs);
        clubsSeries.Add(tenOfClubs);
        clubsSeries.Add(elevenOfClubs);
        clubsSeries.Add(twelveOfClubs);
        clubsSeries.Add(thirteenOfClubs);

        #endregion Clubs Cards Are Added To ClubsSeries List
        #region Clubs2 Cards Are Added To ClubsSeries List

        clubsSeries2.Add(aceOfClubs2);
        clubsSeries2.Add(twoOfClubs2);
        clubsSeries2.Add(threeOfClubs2);
        clubsSeries2.Add(fourOfClubs2);
        clubsSeries2.Add(fiveOfClubs2);
        clubsSeries2.Add(sixOfClubs2);
        clubsSeries2.Add(sevenOfClubs2);
        clubsSeries2.Add(eightOfClubs2);
        clubsSeries2.Add(nineOfClubs2);
        clubsSeries2.Add(tenOfClubs2);
        clubsSeries2.Add(elevenOfClubs2);
        clubsSeries2.Add(twelveOfClubs2);
        clubsSeries2.Add(thirteenOfClubs2);

        #endregion Clubs2 Cards Are Added To ClubsSeries List

        //Diamonds Cards Are Added To DiamondsSeries List
        #region Diamonds Cards Are Added To DiamondsSeries List

        diamondsSeries.Add(aceOfDiamonds);
        diamondsSeries.Add(twoOfDiamonds);
        diamondsSeries.Add(threeOfDiamonds);
        diamondsSeries.Add(fourOfDiamonds);
        diamondsSeries.Add(fiveOfDiamonds);
        diamondsSeries.Add(sixOfDiamonds);
        diamondsSeries.Add(sevenOfDiamonds);
        diamondsSeries.Add(eightOfDiamonds);
        diamondsSeries.Add(nineOfDiamonds);
        diamondsSeries.Add(tenOfDiamonds);
        diamondsSeries.Add(elevenOfDiamonds);
        diamondsSeries.Add(twelveOfDiamonds);
        diamondsSeries.Add(thirteenOfDiamonds);

        #endregion Diamonds Cards Are Added To DiamondsSeries List
        #region Diamonds2 Cards Are Added To DiamondsSeries List

        diamondsSeries2.Add(aceOfDiamonds2);
        diamondsSeries2.Add(twoOfDiamonds2);
        diamondsSeries2.Add(threeOfDiamonds2);
        diamondsSeries2.Add(fourOfDiamonds2);
        diamondsSeries2.Add(fiveOfDiamonds2);
        diamondsSeries2.Add(sixOfDiamonds2);
        diamondsSeries2.Add(sevenOfDiamonds2);
        diamondsSeries2.Add(eightOfDiamonds2);
        diamondsSeries2.Add(nineOfDiamonds2);
        diamondsSeries2.Add(tenOfDiamonds2);
        diamondsSeries2.Add(elevenOfDiamonds2);
        diamondsSeries2.Add(twelveOfDiamonds2);
        diamondsSeries2.Add(thirteenOfDiamonds2);

        #endregion Diamonds2 Cards Are Added To DiamondsSeries List

        //Hearts Cards Are Added To HeartsSeries List
        #region Hearts Cards Are Added To HeartsSeries List

        heartsSeries.Add(aceOfHearts);
        heartsSeries.Add(twoOfHearts);
        heartsSeries.Add(threeOfHearts);
        heartsSeries.Add(fourOfHearts);
        heartsSeries.Add(fiveOfHearts);
        heartsSeries.Add(sixOfHearts);
        heartsSeries.Add(sevenOfHearts);
        heartsSeries.Add(eightOfHearts);
        heartsSeries.Add(nineOfHearts);
        heartsSeries.Add(tenOfHearts);
        heartsSeries.Add(elevenOfHearts);
        heartsSeries.Add(twelveOfHearts);
        heartsSeries.Add(thirteenOfHearts);

        #endregion Hearts Cards Are Added To HeartsSeries List
        #region Hearts2 Cards Are Added To HeartsSeries List

        heartsSeries2.Add(aceOfHearts2);
        heartsSeries2.Add(twoOfHearts2);
        heartsSeries2.Add(threeOfHearts2);
        heartsSeries2.Add(fourOfHearts2);
        heartsSeries2.Add(fiveOfHearts2);
        heartsSeries2.Add(sixOfHearts2);
        heartsSeries2.Add(sevenOfHearts2);
        heartsSeries2.Add(eightOfHearts2);
        heartsSeries2.Add(nineOfHearts2);
        heartsSeries2.Add(tenOfHearts2);
        heartsSeries2.Add(elevenOfHearts2);
        heartsSeries2.Add(twelveOfHearts2);
        heartsSeries2.Add(thirteenOfHearts2);

        #endregion Hearts2 Cards Are Added To HeartsSeries List

        //Spades Cards Are Added To SpadesSeries List
        #region Spades Cards Are Added To SpadesSeries List

        spadesSeries.Add(aceOfSpades);
        spadesSeries.Add(twoOfSpades);
        spadesSeries.Add(threeOfSpades);
        spadesSeries.Add(fourOfSpades);
        spadesSeries.Add(fiveOfSpades);
        spadesSeries.Add(sixOfSpades);
        spadesSeries.Add(sevenOfSpades);
        spadesSeries.Add(eightOfSpades);
        spadesSeries.Add(nineOfSpades);
        spadesSeries.Add(tenOfSpades);
        spadesSeries.Add(elevenOfSpades);
        spadesSeries.Add(twelveOfSpades);
        spadesSeries.Add(thirteenOfSpades);

        #endregion Spades Cards Are Added To SpadesSeries List       
        #region Spades2 Cards Are Added To SpadesSeries List

        spadesSeries2.Add(aceOfSpades2);
        spadesSeries2.Add(twoOfSpades2);
        spadesSeries2.Add(threeOfSpades2);
        spadesSeries2.Add(fourOfSpades2);
        spadesSeries2.Add(fiveOfSpades2);
        spadesSeries2.Add(sixOfSpades2);
        spadesSeries2.Add(sevenOfSpades2);
        spadesSeries2.Add(eightOfSpades2);
        spadesSeries2.Add(nineOfSpades2);
        spadesSeries2.Add(tenOfSpades2);
        spadesSeries2.Add(elevenOfSpades2);
        spadesSeries2.Add(twelveOfSpades2);
        spadesSeries2.Add(thirteenOfSpades2);

        #endregion Spades2 Cards Are Added To SpadesSeries List       

        #region Cards Are Added To Deck

        deck.AddRange(jokers); //Jokers List Is Added To Deck;
        deck.AddRange(clubsSeries); //Clubs Series List Is Added To Deck;
        deck.AddRange(diamondsSeries); //Diamonds Series List Is Added To Deck;
        deck.AddRange(heartsSeries); //Hearts Series List Is Added To Deck;
        deck.AddRange(spadesSeries); //Spades Series List Is Added To Deck;
        deck.AddRange(jokers2); //Jokers List Is Added To Deck;
        deck.AddRange(clubsSeries2); //Clubs Series List Is Added To Deck;
        deck.AddRange(diamondsSeries2); //Diamonds Series List Is Added To Deck;
        deck.AddRange(heartsSeries2); //Hearts Series List Is Added To Deck;
        deck.AddRange(spadesSeries2); //Spades Series List Is Added To Deck;

        #endregion Cards Are Added To Deck

    }

    [Command]

    public void CmdGenerateCardsList()
    {
        var tempHand = deck.GetRange(0, 14);

        foreach (var i in tempHand)
        {
            if (isLocalPlayer)
            {
               hand.Add(i);
               deck.Remove(i);
            }
        }
            CmdShowCards();
    }

    [Command]

    public void CmdShowCards()
    {
        if (isLocalPlayer)
        {
            for(int i = 0; i < hand.Count; i++)
            CmdGeneratePlayerCards(hand[i]);
        }
    }

    [Command]

    public void CmdInstantiateCards(Card c)
    {
        GameObject newestCard = Instantiate(cardPrefab, Vector3.zero, Quaternion.identity);
        NetworkServer.Spawn(newestCard, connectionToClient);


        CardInfo ci = newestCard.GetComponent<CardInfo>();
        ci.card = c;

        int cardImageIndex = c.subValue * 4;

        switch (c.imgSuit)
        {
            case Card.ImageSuit.clubsImg:
                cardImageIndex += 1;
                break;

            case Card.ImageSuit.diamondsImg:
                cardImageIndex += 2;
                break;

            case Card.ImageSuit.heartsImg:
                cardImageIndex += 3;
                break;

            case Card.ImageSuit.spadesImg:
                cardImageIndex += 4;
                break;
        }

        ci.GetComponent<Image>().sprite = cardImages[cardImageIndex];

        RpcParenting(newestCard);

    }

    [ClientRpc]

    public void RpcParenting(GameObject card)
    {
        if (isLocalPlayer)
        {
            card.transform.SetParent(playerArea.transform, false);
        }
    }
}

[System.Serializable]

public class Card
{
    public int realValue;
    public enum Suit { joker, clubs, diamonds, hearts, spades, okeySuit }
    public Suit suit;
    public enum ImageSuit { jokerImg, clubsImg, diamondsImg, heartsImg, spadesImg }
    public ImageSuit imgSuit;
    public int subValue;
    public enum Color { cream, blue }
    public Color backFace;
} 


Solution 1:[1]

There is a way to bypass authority checks with [Command(requiresAuthority = false)] But maybe it's a design problem and you need to give authority somewhere to your calling client

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Romain Bitard