Object reference not set to an instance of an object. ( FirstPersonController)

Hi,
I Here’s a part of my edited FirstPersonController script:

public void Update()
        {
            var hud = GetComponent<HUD>();
            if (hud.Inventory.enabled == true || hud.Pause.enabled == true)
            {
                m_MouseLook.XSensitivity = 0f;
                m_MouseLook.YSensitivity = 0f;
            }
       }

When I start a game an error is displaying, How to fix it?

PS: Error in 4th line of code.

So hud is likely null. Is the HUD component attached to the same GameObject to which this script is attached?