Spawned in Prefab Object keeps spawning behind the scene

I have a piece of a code that summons up a prefab image. For some reason though, the object I am creating keeps placing the object behind another object. I’ve tried modifying the layer and proximity to the camera of both objects, but nothing has worked. The object my prefab is behind is also a prefab if that means anything. THe game is also in 2D if that helps. Can anyone help me? Thanks

If you are using a sprite renderer then the Z value of the position is irrelevant unless the sorting layer of the renderer is Default.

SpriteRenderers don’t use regular layers, they use sorting layers. If you want your prefab to appear in front of something else set it’s layer to a higher one or set it’s sorting order to a higher number.