isPointerOverGameObject doesn't work?

Hi, I’m trying to make Diablo like game and working currently on UI. It’s all kept simple but I can’t manage one thing. There’s a wide bar at the bottom of screen with some info (something like Diablo 1 UI). And what I would like to do is to make this bar block my moving function. So when I move mouse over UI the bool value goes true and my other scripts are being changed. Sounds simple, but it isn’t. For me at least. So I’ve tried many things but can’t make it works.
using UnityEngine;
using UnityEngine.EventSystems;

 public class blocking : MonoBehaviour {
 
     public bool isOverUI = false;
 
 
     private void Update()
     {
         if (Input.GetMouseButton(1))
         {
             if (EventSystem.current.IsPointerOverGameObject())
                 isOverUI = true;
         }
         else
             isOverUI = false;
     }
 
 
 }

The error after pressing right mouse button goes like that “NullReferenceException: Object reference not set to an instance of an object blocking.Update ()”.

I appreciate any help.

[90190-beztytułu.jpg|90190]

If you use IsPointerOverGameObject() without a parameter, it points to the “left mouse button”. You have to add a pointerId to the function.