Any reason why script vanishes from prefab when instantiated?

I have a Player prefab. It has a few scripts on it - but one of them, when added to a prefab, is not there when the prefab instantiates. Only that script disappears, the rest are fine.

To work round, I call AddComponent() in OnStartServer, and all is then fine, but I’m just wondering what would cause a script to vanish from a prefab at instantiation time with no errors…

Are you able to provide your Start() and Awake() functions of the offending script, and maybe a view of the inspector of the prefab?

With you using OnStartServer I imagine this is with UNET? Do you have the same prefab in the list of spawnable objects in your NetworkManager? I had a similar problem and found that it was set to a different prefab with a very similar name.

Looked like a issue with the editor, see my comment above. By tweaking the NetworkLobbyManager in the Inspector it resolved itself.

If I manage to reproduce I’ll raise a bug report. It’s now all working OK, even when I add extra scripts.