Object is invisible when there is another object behind

For some reason this happens. How can this be fixed? I also have other objects that don’t show up until I am really close to them, but they still have this type of behavior.

This may be because the walls have a transparent shader and they are being rendered after the lights because of the renderQueue. You can alter it by using

GetComponent<Renderer>().material.renderQueue = 0 - 5000