6 Years Ago
Had an issue where if you reconnected to a game, you weren't holding anything. Turned out this is what happens on reconnect: 1. OnEntitySpawnMessage. HeldItem entity comes through on its own 2. It's created 3. Deserialize called. 4. SetParent called, but parent is null since it's coming on its own. 5. OnClientInitialize called 6. OnEntitySpawnMessage. HeldItem entity comes through as a child of the user 7. Warning shown that it already exists 8. Deserialize called. 9. SetParent called. *Parent is now set.* We can now call SetItemHolder any time 10. OnClientInitialize _skipped automatically_ in NetworkEntity as it's already been called To fix I added moved the backup SetItemHolder call in Deserialize to OnPostDeserialize, which is called after SetParent.