how to save a prefab of a object during play mode

so here it is i have two scenes… one is the playing scene were the game is played. and the second scene is were the player can customized guns by instantiating things onto the gun

so the question becomes how to save a prefab of the gun and save it. is this possible to do?

Creating prefabs during runtime is only possible if running the game from within the Unity Editor. If you need to create prefabs during runtime of an actual build, you have to create a workaround. For example, you could always use the same prefab which has just the most basic components (MeshRenderer, MeshFilter) and save the information that fills these components; Upon instatiation the prefab, you then use this information to assign the right mesh, materials, children and so on.

I think the thing you are trying to do is, storing a gameobject and using it later. You don’t need to use prefabs for this.

You can just declare a public static gameobject and store your gameobject on it, then whenever you need it Instantiate it from your public static variable.