I am trying to to test with an if statement for when a gameObject is between two different x locations using the following code:

if(spiralY.transform.position.x >= -16 && spiralY.transform.position.x <= 19){ renderer.enabled = true; print("location" + spiralY.transform.position.x); }

I am getting a NullReferenceException error. Is there another way to test the location of a gameObject?

When you get a null reference exception error, you're trying to reference an object that doesn't exist. That code would work, but you have to reference objects correctly by making sure that "spiralY" and "renderer" exist.