Spawning object on host only appears on host and not for other clients

Hey! So I’m working on a buildmode system for my game and I have run into an issue.

When using NetworkObject.Spawn() on the host, it only spawns the object passed on the host not the clients. For example, when a client places an object on their end, it calls a server RPC to which on the server side the object is meant to be spawned for ALL clients.

Everything building wise works and I have put all of my prefabs used in the NetworkPrefabsList in the NetworkManager.

Here is the code for the server RPC and the function spawning the object into the game after being placed:

[ServerRpc (RequireOwnership = false)]
public void PrepareBuildForManipulationServerRpc(string function, string prefabName, Vector3 pos = new Vector3(), int rotationY = 0) {
ManipulateBuild(function, prefabName, pos, rotationY);
}

void ManipulateBuild(string function, string prefabName, Vector3 pos, int rotationY) {
Buildable buildsettings = buildables.Find(prefabName).GetComponent<Buildable>();

if (function == "Spawn") {
GameObject newPrefab = Instantiate(buildsettings.prefab);

Destroy(newPrefab.GetComponent<BoxCollider>()); //Destroy box collider so it does not interfere with prompts etc

NetworkObject networkObject = newPrefab.AddComponent<NetworkObject>(); //Adding network object for syncronisation

newPrefab.transform.SetLocalPositionAndRotation(pos, Quaternion.Euler(0, rotationY, 0));
newPrefab.name = prefabName;

networkObject.SpawnWithObservers = true;
networkObject.Spawn(true);
newPrefab.transform.SetParent(GameObject.Find("Builds").transform, true);

} else if (function == "Destroy") {
foreach (Transform build in GameObject.Find("Builds").transform) {
if (build.localPosition == pos) {
Destroy(build.gameObject);
break;
}
}
}
}

I appreciate all help and also feel free to ask questions!

This won’t work.

If I’m not mistaken the NetworkObject component has to be already added to the prefab. Without it, it’s not a “network” prefab and will not spawn properly. I’m surprised that NGO does not complain neither on startup nor when spawning this object. Or are you getting errors/warnings but ignored them?

Note that passing a string “function” is wasteful when the same can be done with an enum. It’s also likely unnecessary to pass the “prefabName” too because the GameObject name will not be synchronized anywayw. If you need it to be synchronized for debugging purposes, make it a separate RPC method that you only call in editor to reduce the overhead of this RPC.