Stuttering Player Movement

Hey guys, currently when my player is moving he is stuttering. I don’t know how I should fix that. Hope that someone has a solution.

Here’s my movement script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movement : MonoBehaviour
{

//Variables
public CharacterController controller;
public float gravity = -9.81f;
public Transform groundCheck;
public float groundDistance = 0.4f;
public LayerMask groundMask;
public float jumpHeight = 3f;
public float speed;

Vector3 velocity;
bool isGrounded;
private bool canDoubleJump;

void Start()
{

}

void Update()
{

  //Gravity & GroundCheck
  isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

  if(isGrounded && velocity.y < 0)
  {
    velocity.y = -4f;
  }

  //Dash
  if (Input.GetKeyDown(KeyCode.LeftShift))
  {
       speed = 14;
  }

  if (Input.GetKeyUp(KeyCode.LeftShift))
  {
       speed = 7f;
  }

  //Movement
  float x = Input.GetAxisRaw("Horizontal");
  float z = Input.GetAxisRaw("Vertical");

  Vector3 move = transform.right * x + transform.forward * z;

  velocity.y += gravity * Time.deltaTime;
  controller.Move(move * speed * Time.deltaTime);
  controller.Move(velocity * Time.deltaTime);

  //Gravity changing with button
  if(Input.GetKey("2"))
  {
    gravity = -0.2f;
  }

  if(Input.GetKey("1"))
  {
    gravity = -20f;
  }

  //Jump / DoubleJump
  if(isGrounded)
  {
    canDoubleJump = true;
  }

  if(Input.GetButtonDown("Jump"))
  {
    if (isGrounded) {
    velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
  } else {
    if (canDoubleJump == true) {
    velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
    canDoubleJump = false;
    }
  }

}

}
}

Try changing Update to FixedUpdate. You should generally use FixedUpdate whenever you call physics function every frame.

When I use FixedUpdate it’s stuttering even more.