Object changing parents causes it to disappear after Spawn

Hi all, I’ve run into an interesting scenario. I’m trying to clean things up on the client end of the networking by putting spawned objects under the same parent as what it’s listed under on the server. The way I found after doing some searching is to do this:
For commands:

build = Instantiate(spawnObject, targetSpot.transform.position, targetSpot.transform.rotation) as GameObject;
    if (build.GetComponent<parentSetting>() != null)
    {
        parentSet = build.GetComponent<parentSetting>();
        parentSet.parentObject = parentID;
    }
    NetworkServer.Spawn(build);

And on the object:

[SyncVar]
    public NetworkInstanceId parentObject;
    public GameObject parent; //Just for looking at via the inspector

    void Start()
    {
        parent = ClientScene.FindLocalObject(parentObject);
        if (parent.transform.childCount > 0)
        {
            transform.SetParent(parent.transform.GetChild(0));
        }
        else
        {
            transform.SetParent(parent.transform);
        }
    }

But here’s the issue: Some objects either don’t get spawned, or get removed after being spawned if they have the script on them that changes their parent. And sometimes, if they do show up, the parent-child is reversed, where the object that was supposed to be the parent ends up being the child.
I get no errors, no warnings, just this weird behavior. If I disable the script, it spawns as normal but unparented.

Any suggestions would be appreciated.

I just want to note that I have the script to change parents on thousands of objects (mostly trees that are spawned by the server) and most of the objects spawn, change parents, and are still visible. Occasionally, such when an object is being spawned from a client interacting with a script, the object is missing.