Inventory Right Click: NullReferenceException: Object reference not set to an instance of an object

I haven’t been able to find any similar posts on why I’m getting this error. I’m creating an inventory and everything is working so far, but when I decided to add a right click functionality to it it gives me this error every time I right click an Item, note it only happens when I click on an Item not when clicking on empty slots.

The error:
NullReferenceException: Object reference not set to an instance of an object
Inventory.DrawInventory () (at Assets/C#_projects/Inventory/InventoryScripts/Inventory.cs:81)
Inventory.OnGUI () (at Assets/C#_projects/Inventory/InventoryScripts/Inventory.cs:53)

Rect slotRect = new Rect(x*120,y*120,100,100);
				GUI.Box (new Rect(slotRect), "", skin.GetStyle("Slot"));
				slots _= inventory*;*_

_ Item item = slots*;
if(slots.itemName != null)
{
GUI.DrawTexture (slotRect, slots.itemIcon);
if(slotRect.Contains(e.mousePosition))
{
CreateTooltip(inventory);
showTooltip = true;*_

* if(e.button == 0 && e.type == EventType.mouseDrag && !draggingItem)*
* {*
* draggingItem = true;*
* prevIndex = i;*
_ draggedItem = slots*;
inventory = new Item();
}
if(e.type == EventType.mouseUp)
{
inventory[prevIndex] = inventory;
inventory = draggedItem;
draggingItem = false;
draggedItem = null;
}*_

* if(e.isMouse && e.type == EventType.mouseDown && e.button == 1)*
* {*
* if(item.itemType == Item.ItemType.Consumable)*
* {*
* print(“num num”);*
* }*
* }*

* }*

Figured it out needed to add

&& draggingItem

to the if statment