Netcode is brand new for me and I’m trying to sync Instantiate prefabs over the network. I get this error evertime.
“Spawning NetworkObjects with nested NetworkObjects is only supported for scene objects. Child NetworkObjects will not be spawned over the network!
UnityEngine.Debug:LogError (object)”
thats what the prefabs looks like

Thats the code for procedural generation to generat a Dungeon:
using System.Collections;
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
public class DungeonGeneration : NetworkBehaviour
{
int _Wall = 0;
int _PackedDeliveryStation = 1;
int _Stair = 2;
int _BigRoom = 3;
private float _time;
private float probabilityForFour = 0.02f;
[Header("Dungeon parts")]
[SerializeField] private GameObject[] Dungeonparts;
bool onetime = true;
bool StopPlaceWall = false;
int _RandomNumber = 1;
private void Awake() {
if (!IsServer) return;
_time = Random.Range(0.0001f, 3.2002f);
generationManager.PlusPart();
}
//Checks whether the route would be in the wall when created
private void OnTriggerEnter(Collider other) {
if (!IsHost) return;
if (other.transform.tag.Equals("Dungeon"))
StopPlaceWall = true;
}
void Update()
{
if (!IsHost) return;
Debug.Log("hjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
//delay before parts are placed
_time -= Time.deltaTime;
if(_time < 0 && onetime) SpawnNewWElement();
}
void SpawnNewWElement() {
GenerateRandomNumber();
if (generationManager.Stop) _RandomNumber = _Wall;
if (generationManager.SpawnDeliverStation && !StopPlaceWall) {
_RandomNumber = _PackedDeliveryStation;
generationManager.SpawnDeliverStation = false;
}
//Create a wall if the route were in the wall
if (StopPlaceWall) { _RandomNumber = _Wall;
StopPlaceWall = false;
}
//New part is created or part is inserted
var instance = Instantiate(Dungeonparts[_RandomNumber], transform.position, transform.rotation);
var instanceNetworkObject = instance.GetComponent<NetworkObject>();
instanceNetworkObject.Spawn();
StartCoroutine(WaitForDestroy());
onetime = false;
}
//Wait until it is destroyed
IEnumerator WaitForDestroy() {
yield return new WaitForSeconds(5);
Destroy(gameObject);
}
//Random number generator with adjustable probability
void GenerateRandomNumber() {
float randomValue = Random.value;
if (randomValue < probabilityForFour) {
_RandomNumber = _BigRoom;
}
else if(randomValue < .06f) _RandomNumber = _Stair;
else if(randomValue < .34f) {
_RandomNumber = Random.Range(4, 5);
}
else {
_RandomNumber = Random.Range(6, 9);
}
}
}
Can Someone tell me whats the problem is?


