!!!URGENT need help with gravity UGENT!!!

Ok Im making a project and I cant seem to make my character to go DOWN when i jump he either starts flying or gets stuck to ground. my script as is is:

var character: CharacterController;
var speed: float = 5.0;   // moving speed
var direction: float = 1; // direction (-1 means -x)
var directionup: float = 2;
var directionback: float = -1;
var runanimation: AnimationClip;
var placeanimation: AnimationClip;
var attackanimation: AnimationClip;
var dieanimation: AnimationClip;
var idleanimation: AnimationClip;
var jumpanimation: AnimationClip;
var jumpSpeed = 8.0;
var gravity = 20.0;
private var moveDirection = Vector3.zero;

function Start(){	
    	character = transform.GetComponent(CharacterController);
}

function Update(){
	if(Input.GetKey("d")){
    	character.Move(Vector3.forward * speed * direction * Time.deltaTime);
    		animation.Play(runanimation.name);
    	}
    if(Input.GetKey("a")){
    	character.Move(Vector3.forward * speed * directionback * Time.deltaTime);
    		animation.Play(runanimation.name);
    	}
    if(Input.GetKey("w")){
    	character.Move(Vector3.right * speed * directionback * Time.deltaTime);
    	}
    if(Input.GetKey("s")){
    	character.Move(Vector3.right * speed * direction * Time.deltaTime);
    	}
   	if(Input.GetMouseButton(1)){
   		animation.Play(placeanimation.name);
   				animation.Stop(idleanimation.name);
   	}
   	if(Input.GetKey("space")){
   		character.Move(Vector3.up * speed * direction * Time.deltaTime);
   			animation.Play(jumpanimation.name);
   	}
   	if (Mathf.Abs(Input.GetAxis("Vertical")) <= 0.1){
        animation.CrossFade(idleanimation.name);
    }
    if(Input.GetMouseButton(0)){
    		animation.Play(attackanimation.name);
    			animation["attack"].layer = -1;
    				animation.Stop(idleanimation.name);
    }
}
function LateUpdate(){
	 	moveDirection.y -= gravity * Time.deltaTime;
			character.Move(moveDirection * Time.deltaTime);
}
its urgent that i get some help soon Thank you everyone

You almost made it! The trick is to make all vertical movement using moveDirection.y. If the character is grounded, zero it. To jump, set y to an appropriate velocity - but only while it’s grounded, or else your character will go up like a rocket for the eternity!

You just need to change the “if (jump)” to get the gravity/jump effects running:

...
function Update(){
    ...
    // modify the if (Input.getKey("space")) to this:
    if (character.isGrounded){ // only check jump if grounded!
        moveDirection.y = 0; // zero vert speed if grounded
        if (Input.GetKey("space")){ // if jump pressed...
            moveDirection.y = jumpSpeed; // set vert speed to jumpSpeed
            animation.Play(jumpanimation.name); // start your jump animation
        }
    }
    ...