Cant Disable my bool variable

RaycastHit hit;
Ray CheckFloor = new Ray(transform.position, Vector3.down);
if (Physics.Raycast(CheckFloor, out hit, StabilizationHeight))
{
if (hit.collider.tag == “Terrain”)
{
Debug.Log(“Found THIS!”);
Stabilization = true;
}
if (hit.collider.tag != “Terrain”)
{
Debug.Log(“WHERE TERRAIN?!”);
Stabilization = false;
}

Raycast enable public bool Stabilization, but when position > StabilizationHeight bool still working. WHY&!

I’m guessing you want Stabilization to be false if the ray does not hit anything while currently Stabilization is set to false if the ray hits something that is not named “Terrain”. If so you want the following:

RaycastHit hit;
Ray CheckFloor = new Ray(transform.position, Vector3.down);
if (Physics.Raycast(CheckFloor, out hit, StabilizationHeight))
{
    if (hit.collider.tag == "Terrain")
    {
        Debug.Log("Found THIS!");
        Stabilization = true;
    }
    if (hit.collider.tag != "Terrain")
    {
        Debug.Log("NOT TERRAIN!");
        Stabilization = false;
    }
}
else{
    Debug.Log("NOTHING !");
    Stabilization = false;
}