Unknow error "NullReferenceException: Object reference not set to an instance of an object"Solved

Hello, I have an error that appears after a plugins I created.
I really don’t know why this error is displayed

Error log:

Failed to call hook 'SupermarketBuyCommand' on plugin 'RoleplayMarket v1.0.0' (NullReferenceException: Object reference not set to an instance of an object) at Oxide.Plugins.RoleplayMarket.getInformationPlayer (BasePlayer player) [0x00000] in :0 at Oxide.Plugins.RoleplayMarket.SupermarketBuyCommand (ConsoleSystem+Arg arg) [0x00153] in :0 at Oxide.Plugins.RoleplayMarket.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00244] in :0 at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <09575a60985045248bcb43b20faeeb99>:0 at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in :0 at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in :0 (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)



Here’s the code tip according to me error would come
PlayerInfo getInformationPlayer(BasePlayer player)
        {
            var playerInfo = playerData.player.Where(x => x.UserID == player.UserIDString).DefaultIfEmpty(null).FirstOrDefault();
             if (playerInfo != null)
                 return playerInfo;
             return null;
        }​

It is likely the .DefaultIfEmpty(null) is causing this, because that defaults it to null if it fails to find the player, and then you try to perform another operation on it (.FirstOrDefault()). Just removing the .DefaultIfEmpty(null) call should solve this.

Locked automatically