While/if loop problem

I’ve been trying to work it out but i’m really struggling, the loop activates, the boolean (inCover) activates, but when you move away from the object that is raycasted, it doesn’t switch to FPSCam again, and inCover doesn’t turn back to false.

any help greatly appreciated

if (Input.GetKeyDown (KeyCode.C)) {//when the player pressess space
						//check how far they are from the object

			while (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.back), 1) & !inCover) {// cast a ray forward 10
								Debug.Log ("There is something in front of the object!"); // display to the console then change to third person camera
								FPSCam.enabled = false;
								THIRDCam.enabled = true;
								inCover = true;

Considering your code is inside Update() function, do it like this:

if (Input.GetKeyDown (KeyCode.C)) {//when the player pressess space check how far they are from the object
{ 
    if(Physics.Raycast (transform.position, transform.TransformDirection (Vector3.back), 1) && !inCover)
    {// cast a ray forward 10
        Debug.Log ("There is something in front of the object!"); // display to the console then change to third person camera
        FPSCam.enabled = false;
        THIRDCam.enabled = true;
        inCover = true;
    } else 
    {
        FPSCam.enabled = true;
        THIRDCam.enabled = false;
        inCover = false;
    }
}

Note: & is for bitwise operation and && is for ‘AND’