character not jumping

#pragma strict

	var jumps:AudioClip;
	var stopfoot :AudioSource;
	var speed =40;
	var jumpSpeed : float = 10.0f;
	var controller : CharacterController ;
	var turnSpeed: float = 90; // degrees per second
	private var moveDirection : Vector3;

	function Start()
	{
	
	 controller= GetComponent(CharacterController);
	
	}
	
	
	function Update() {
	if(Input.GetKeyDown(KeyCode.RightArrow))
  	transform.Rotate(0, turnSpeed, 0);
  	if(Input.GetKeyDown(KeyCode.LeftArrow))
 	 transform.Rotate(0, -turnSpeed, 0);
 	 moveDirection = Vector3(Input.GetAxis("Horizontal")*10, 1,
	speed);
	if (controller.isGrounded)
{
	if(Input.GetKeyDown(KeyCode.Space))
	{
	moveDirection.y=jumpSpeed;
		Debug.Log("jump");	
	}
	}
	moveDirection *= speed;
	if(!controller.isGrounded)
	{
        moveDirection.y -= 5*Time.deltaTime;
 	Debug.Log("gravity");
       }
      controller.SimpleMove(moveDirection * Time.deltaTime);
}
 
function jump()  {  
	  
	     audio.Stop();
	     audio.PlayOneShot(jumps);
	     animation.Play("jump_pose");
	     yield WaitForSeconds(1f);
	     animation.Play("run");
        }
	    if(transform.position.y<=490)
	            {
			Destroy(this.gameObject);
	            }

tried adding velocity and not using gravity,non of them works.
this is an infinite runner,with player moving constantly with rigid body attach to it.

There code is a real snarl. With respect to the jump, there are two things to check first. Since ‘jumpSpeed’ is a public variable, check the value in the Inspector. The value in code will only be used when the script is attached. Second, you don’t scale ‘Time.deltaTime’ the value you pass to SimpleMove(). SimpleMove() does deltaTime factoring internally.

Other issues not related to the not-working jump:

  • You set ‘z’ to ‘speed’ when you do your arrow key code, but then you again multiply moveDirection by speed on line 34. Remove line 34 and adjust your other values.
  • Lines 51 - 54 are outside of any function.
  • I don’t know your intent, but your structure will allow the player to do an immediate change in direction while jumping.
  • I don’t know your intent, but because of the way you did your arrow keys, the player cannot move on the diagonal.