Help, How to solve this NullReferenceException? [DONE]

So, I was trying to program a equipment item for an rpg, but when I try to call a method I get a NullReferenceException, can anyone help me to solve this?

Equipment Script

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

[CreateAssetMenu (fileName = "New Equipment", menuName = "Inventory/Equipment")]
public class Equipment : Item
{
    public int armorMod;
    public int dmgMod;
    public EquipmentSlot equipmentSlot;

    public override void Use ()
    {
        base.Use ();

        EquipmentManager.instance.Equip (this); // Error happens here.
        RemoveFromInventory ();
    }
}

public enum EquipmentSlot {Head, Chest, Legs, Feet, rightHand, leftHand}

Equipment Manager Script

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

public class EquipmentManager : MonoBehaviour
{

    #region Singleton

    public static EquipmentManager instance;

    void Awake ()
    {
        instance = this;
    }

    #endregion

    Equipment[] currentEquip = new Equipment[6];
    Inventory inventory;

    public void Equip (Equipment newItem)
    {
        int slotIndex = (int)newItem.equipmentSlot;
        Equipment oldEquip;

        if (currentEquip [slotIndex] != null)
        {
            oldEquip = currentEquip [slotIndex];
            Inventory.instance.Add (oldEquip);
        }

        currentEquip [slotIndex] = newItem;
        Inventory.instance.AddEquipment (newItem);
    }
}

Edit:
So, I managed to make it work, there was a lot wrong with the code, and not only with the classes I posted, now I have a functioning equipment inventory (I’m so proud), thanks :smile:

I think you’re fail to initialize public EquipmentSlot equipmentSlot;on line 10.
Perhaps just give it a default public EquipmentSlot equipmentSlot = (EquipmentSlot)0;

Is your EquipmentManager in your scene?

equipmentSlot is a enum, so I can edit it on the game object

no… I’ll try that and come back with the result, thx

Okay, I added the EquipmentManager script under a empty game object and now I’m getting a different error lol

And what is that error? Post the error copied from the console, that helps. It’s good that you did note what line your error is at, but also adding the console message is a big help as well.

I’ll do that next time I need some help, thx, but I’ve fixed this problem already