Problem with ReplacePlayerForConnection for characterselection

So I am working on a multiplayer game, where the players should be able to choose their character at the beginning of a match. I am using a NetworkLobbyManager, and after struggling with trying to change the player prefab before joining the game, I am now using a single prefab playerController which contains every character as children, and a selection menu, which is open upon starting the server. After confirming the character selection, the playerController and its children get destroyed, with the exception of the chosen character.
For this I am using the ReplacePlayerForConnection function, which seems to work fine for the Host, but I get a NullReference exception when I try the same as a client. The correct prefab is isolated and the rest destroyed, but I can’t control the character, as the player is not correctly set.
This is the code in playerController:

public void chooseCharacter()
{
    switch (chosenCharacter)
    {
        case e_Characters.Zack: destroyAllOthers("Zack"); break;
        case e_Characters.Celeste: destroyAllOthers("Celeste"); break;
        case e_Characters.Black: destroyAllOthers("Black"); break;
        case e_Characters.Clutch: destroyAllOthers("Clutch"); break;
        case e_Characters.Igor: destroyAllOthers("Igor"); break;
        case e_Characters.Gunther: destroyAllOthers("Gunther"); break;
        case e_Characters.Li: destroyAllOthers("Li"); break;
        case e_Characters.Violet: destroyAllOthers("Violet"); break;
        case e_Characters.Chucker: destroyAllOthers("Chucker"); break;
        default: break;
    }
}
void destroyAllOthers(string _sChosenOne)
{
    foreach(Transform go in transform)
    {
        if(go.gameObject.name == _sChosenOne)
        {
            go.gameObject.transform.SetParent(transform.parent);
            go.gameObject.transform.position = transform.position;
            go.gameObject.SetActive(true);
            CmdReplace(go.gameObject);
        }
        else
        {
            go.gameObject.SetActive(false);
        }
    }
    Destroy(gameObject);
}
[Command]
void CmdReplace(GameObject _goReplacement)
{
    NetworkServer.ReplacePlayerForConnection(connectionToClient, _goReplacement, playerControllerId);
}

And this is the Error Message:

I seriously hope somebody has an answer, as I have been googling for hours now and I really have no Ideas left.

First, does the gameObject you’re passing as the command parameter has a NetworkIdentity component? That’s a requirement to pass GameObject’s between clients and server.

Second, you’re calling the command in destroyAllOthers passing a child of the object that has that script attached, and at the end of the function you’re destroying the gameObject (which destroys all it’s childern.

If you war calling a normal function I’d say there’s no problem there, but I think what you’re doing will work only if the command is sent immediatelly when you call the command function. I wouldn’t relay on that, I think Unity will wait till the end of the frame to actually send the message to the server, so by that point the gameObject is probably already destroyed. So, see what happens if you don’t call the Destroy(gameObject) line, or if you delay that destroy one frame.