manipulating position.y in unity

Hello, i’m trying to create script that will push player to the sky and if it reach equal lvl, it will fall down.

Here’s part of code

if (controller.isGrounded) {//if controller is on the ground
			isFlying=false;//set that it is not flying

			if (Input.GetButton ("Jump"))//if button jump
			{	
				isFlying=true;//the thing started to be in air
				jumpReached = false;//but it doesnt reach the max altitude
				jumpStarted=false;//the jump mechanism is not started yet
}

		}
		if (isFlying == true && jumpReached==false && jumpStarted ==false) {//if thing is flying, the altitude is not reached and jump procedure is not started
			moveDirection.y += 0.9F;//set object 0,9 above ground block
			maxJump = moveDirection.y + 10F;//set altitude 10 blocks above ground
			jumpStarted = true;//initial jump procedure ended
		}
		else if(isFlying==true && jumpReached==false && jumpStarted ==true)//if thing is flying, altitude is not reached and jump has started
		{
		if (moveDirection.y >= maxJump)//if altitude reached
				{
				jumpReached = true;//now its time to fall down
				maxJump = maxJump - 10F;//refreshing maxjump 
				}
			moveDirection.y += 3F;//if not give the player strength to fly to the air ;)
		}
if (isFlying==true && jumpReached==true) {//if player is in the air and it should fall down
			{
			moveDirection.y -= 0.95F;//decrease player position by 0.95
			controller.Move (moveDirection * Time.deltaTime);
			}
			if(controller.isGrounded == true)//if player is on the ground
				{
				isFlying =false;
				jumpReached = false;
				jumpStarted=false;
				maxJump = 0;
				}//reset everything
		}
		moveDirection.y -= 0.60F;//if nothing happens players is going to fall
		controller.Move (moveDirection * Time.deltaTime);

The problem is that I can’t compare position of player to maxJump. Any idea?

Ok, done. I just create two transform value; one actual position of object and second - where is the limit. Secondly I used sqrMagnitude, and when the objects are too close it is going to fall.

asuming thi script is attached to your player, use transform.position.y tyo refer to its height not moveDirection.y