Jumping script OnCollisionStay didn't work

Hey im trying to make a jumping script and i need to make it that i can jump only when i am on the ground i have this (sorry for my english im from poland)

#pragma strict
var height = 10;
var isFalling = false;
function Update () {

	if (Input.GetKeyDown(KeyCode.Space) && isFalling == false)
		rigidbody2D.velocity.y = height;
		isFalling = true;
	function OnCollisionStay ()
	isFalling = false;

when im press space i jump and isFalling variable is true but when i fell and touch the ground again isFalling is still true help

here a link for a short video that’s help you guys better understand this
situation: Click here

You have a 2D app (based on your ‘rigidbody2D’, but OnCollisionStay() is 3D. You want OnCollisionStay2D().

function OnCollisionStay2D ()

And you could use OnCollisionEnter2D(). Note if you start putting other objects in the scene, you’ll have to change/expand this code.