If statement is false for some reason

I got this

and I made it into this:

bool AMyProjectCharacter::HipToLedge(USkeletalMeshComponent* PlayerMesh, FName SocketName)
{
    if(PlayerMesh->GetSocketLocation(SocketName).Z - HeightHitResult.Location.Z >= -50.f && PlayerMesh->GetSocketLocation(SocketName).Z - HeightHitResult.Location.Z <= 0.f)
    {
        return true;
    }
    return false;
}

but for some reason it always returns false while in Blueprints it is fine