NullReferenceExepction Error [duplicate]

I'm getting error an error on this piece of code:

if (EventSystem.current.IsPointerOverGameObject())
return;


The error: NullReferenceExpection: object reference not set to an instance of an object playercontroller.update() { at assets/script/palyer/playercontroller.cs:21)

Any solution to this?

• Maybe the EventSystem object was removed from the canvas. Right click -> UI -> EventSystem to add it back – BatteryAcid Aug 14 '20 at 16:39

The error message is there to tell you what the problem is. A NullReferenceException means you tried to access a variable that is currently null:
Object a = null;

So in your case, assuming EventSystem is a class, EventSystem.current is null.