Object reference not set to an instance of an object

So this is my code :

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

public class PlayerMovement : MonoBehaviour
{

//Movements Var
public CharacterController controller;
public float speed = 6.5f;
public float jumpHeight = 4f;
public float sprintSpeed = 8.5f;
bool isSprinting;
bool isLShiftKeyDown;

//Stamina var
public int currentStamina;
public int maxStamina;
public StaminaBar staminaBar;

//Gravity Var
Vector3 velocity;
public float gravity = 9.81f;
public Transform groundCheck;
public float groundDist = 0.4f;
public LayerMask groundMask;
bool isGrounded;

// Start is called before the first frame update
void Start()
{
    currentStamina = maxStamina;
    staminaBar.SetMaxStamina(maxStamina);
}

// Update is called once per frame
void Update()
{   
    //Updates Stamina Bar
    staminaBar.SetStamina(currentStamina);

    //GroundCheck
    isGrounded = Physics.CheckSphere(groundCheck.position, groundDist, groundMask);

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

    //Getting movements input

    float x = Input.GetAxis("Horizontal");
    float z = Input.GetAxis("Vertical");

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

    isLShiftKeyDown = Input.GetKey(KeyCode.LeftShift);

    //Moves the player
    if(isLShiftKeyDown == true)
    {
        controller.Move(move * sprintSpeed * Time.deltaTime); 
        currentStamina -= 1;
    }

    if(isLShiftKeyDown == false)
    {
        controller.Move(move * speed * Time.deltaTime);
    }

    //Jumping Script
    if(Input.GetButtonDown("Jump") && isGrounded)
    {
        velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
    }

    velocity.y += gravity * Time.deltaTime;

    controller.Move(velocity * Time.deltaTime);
}

}

When I try to run the code in my game, an error appears “Object reference not set to an instance of an object” for the line 33 and 40 of my code. I’m not sure why it does that. Can anybody help me?