variable's value is not changing

I really don’t understand what’s happening with this code :

var jumpHeight = 8;
var isFalling = false;

function Update () {
	if ( !isFalling && Input.GetKeyDown ( KeyCode.W ) )
		rigidbody.velocity.y = jumpHeight;
		isFalling = true;

function OnCollisionStay()
	isFalling = false;

I believe that by that code, it means when I press button W, the isFalling will be true, but it is not, instead, I need to press button W twice to make it to true, I really wonder somebody to help me out with this.

If your object is touching anything then isFalling will never be true, because your collision code says to reset it.

When you press the button the first time they object is projected into the air, but the collision happens first resetting the variable. On the second press the object is not touching so the value becomes true.

OnCollisionStay is very expensive, avoid it if you can. I would have thought OnCollisionEnter would fix your problem.