Trouble accessible field in custom classSolved
static Dictionary<ulong, PVEStatsData> Cachedplayerstats = new Dictionary<ulong, PVEStatsData>();

private class PVEStatsData
        {
            public int heavyKills = 0;
            public int scientistkills = 0;
            public int murdererkills = 0;
            public int scarecrowkills = 0;
            public int points = 0;
            public int rank = 0;
            internal static void TryLoad(ulong id)
            {
                if (Cachedplayerstats.ContainsKey(id)) return;


                PVEStatsData data = Interface.Oxide.DataFileSystem.ReadObject<PVEStatsData>($"NPCKillCounter/{id}");

                if (data == null) data = new PVEStatsData();
                
                    
                
                
                data.Save(id);
                Cachedplayerstats.Add(id, data);

                
            }
                                                        
            internal static void Reset(ulong id)
            {
                PVEStatsData data = Interface.Oxide.DataFileSystem.ReadObject<PVEStatsData>($"NPCKillCounter/{id}");

                if (data == null) return;

                data = new PVEStatsData();



                data.Save(id);
                

            }
            internal static void resetcache(ulong id)
            {
                if (!Cachedplayerstats.ContainsKey(id)) PVEStatsData.TryLoad(id);
                Cachedplayerstats[id].heavyKills = 0;
                Cachedplayerstats[id].scarecrowkills = 0;
                Cachedplayerstats[id].scientistkills = 0;
                Cachedplayerstats[id].murdererkills = 0;
                Cachedplayerstats[id].points = 0;
                Cachedplayerstats[id].rank = 0;
            }


            internal void Save(ulong id) => Interface.Oxide.DataFileSystem.WriteObject(($"NPCKillCounter/{id}"), this, true);
        }


void RankScoreboard()
        {
            Dictionary<string, string> toprank = new Dictionary<string, string>();
            List<PVEStatsData> toprankdata = Cachedplayerstats.OrderByDescending(d => d.rank).Take(5).ToList();

            foreach (var playerData in toprankdata)
                toprank.Add(playerData.rank.ToString(), playerData.points.ToString());

            PrintToChat("Ranks:",toprank.ToArray<KeyValuePair<string, string>>());
        }

I have this code that gets the top 5 players by rank, and then prints it to the chat, like a leaderboard. But this part: (d => d.rank) I get this error: 

Error CS1061	'KeyValuePair<ulong, NPCKillCounter.PVEStatsData>' does not contain a definition for 'rank' and no accessible extension method 'rank' accepting a first argument of type 'KeyValuePair<ulong, NPCKillCounter.PVEStatsData>' could be found (are you missing a using directive or an assembly reference?)

I don't understand why, please help.

In Rankscoreboard you are using Cachedplayerstats and try to access kvp.rank but it is a KeyValuePair not PVEStatsData so you cannot access it. Instead use d.Value.rank at least.
Locked automatically