So I tried to make a bunch of scripts for the past hour or so that would get the players that got the highest amount of coins but none worked. I wanted it 1-3rd most but all of my scripts failed. I think I made 13 attempts or so. Please help ASAP
players = game:GetService("Players") highestValue = nil for i, v in pairs(players:GetChildren()) do if v:FindFirstChild("leaderstats") ~= nil then for ii, vv in pairs(v.leaderstats:GetChildren()) do if highestValue == nil or vv.Value > highestValue then highestValue = vv.Value end end end end
That should find the leaderstat with the highest's Value and give you that number
This I'm not 100% about, but it should give you the highest leaderstat instance and that stat's Value. It may take some experimenting if it doesn't work, but this is the general idea that I would use.
players = game:GetService("Players") highestValue = nil highestStat = {nil, 0] for i, v in pairs(players:GetChildren()) do if v:FindFirstChild("leaderstats") ~= nil then for ii, vv in pairs(v.leaderstats:GetChildren()) do if highestValue == nil or vv.Value > highestValue then highestValue = vv.Value if highestValue > highestStat[2] or highestStat[1] == nil then highestStat[1] = vv.Name highestStat[2] = highestValue end end end end end