Character Jumping Not Working Sometimes

Hello, I have a 2D sidescroller game where the player can make the character jump by pressing the space bar. However, sometimes the character does not jump when I press space.

So, I have this function called PlayerMovement () which is being called every frame through Update. Simple.

Then, in the PlayerMovement function, I have a variable and an if statement:

var controller : CharacterController = GetComponent(CharacterController);

  if (controller.isGrounded)

if (Input.GetButtonDown(“Jump”))
moveDirection.y = playerJumpSpeed;
audio.clip = jumpSound;

playerJumpSpeed is a variable which never changes.

moveDirection is a Vector2 variable which is used to move the controller with:

controller.Move(moveDirection * Time.deltaTime);

Anybody know what the problem could be?

Okay, I figured it out. Now I’m using Input.GetButton instead of Input.GetButtonDown. Seems to work!