-
What do you want to achieve? I want my leaderboard to be in order of stats.
-
What is the issue? Not in order (stat order)
-
What solutions have you tried so far? Looked all over the dev forum, not even a post about any type of best stat leaderboard, that works atleast. I even tried ChatGPT, no use.
Here is my full script because I am not sure where the problem lies.
local DSS = game:GetService("DataStoreService")
local EN = require(game.ReplicatedStorage.Modules.EternityNum)
local HTTP = game:GetService("HttpService")
local Top = DSS:GetOrderedDataStore("TopPlayers#002")
local TOPTYPE = DSS:GetDataStore("TopType#002")
local LB = script.Parent
local function update()
local success, errorMessage = pcall(function()
local Data = Top:GetSortedAsync(false,100)
local Page = Data:GetCurrentPage()
for rank, data in ipairs(Page) do
local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
local userId = game.Players:GetUserIdFromNameAsync(userName)
local DATA2 = TOPTYPE:GetAsync(userId)
local DataVal = EN.lbdecode(data.value)
local isOnLeaderboard = false
for i, v in pairs(LB.SurfaceGui.ScrollingFrame:GetChildren()) do
if v:IsA("Frame") then
if v.playerName.Text == userName then
break
end
end
end
if DataVal and isOnLeaderboard == false then
local NewLBFrame = script.Sample:Clone()
local statLabel = NewLBFrame.value
NewLBFrame.playerName.Text = userName
local current = ""
if DATA2 == "Saffron" then
current = "Saffron"
statLabel.TextColor3 = Color3.fromRGB(255, 153, 51)
elseif DATA2 == "Truffle" then
current = "Truffle"
statLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
elseif DATA2 == "Caviar" then
current = "Caviar"
statLabel.TextColor3 = Color3.fromRGB(26, 26, 26)
elseif DATA2 == "Gourmet" then
current = "Gourmet"
statLabel.TextColor3 = Color3.fromRGB(71, 135, 213)
elseif DATA2 == "Cake" then
current = "Cake"
statLabel.TextColor3 = Color3.fromRGB(208, 135, 213)
elseif DATA2 == "Cookies" then
current = "Cookies"
statLabel.TextColor3 = Color3.fromRGB(206, 138, 56)
elseif DATA2 == "Fork" then
current = "Fork"
statLabel.TextColor3 = Color3.fromRGB(94, 94, 94)
elseif DATA2 == "Spoon" then
current = "Spoon"
statLabel.TextColor3 = Color3.fromRGB(159, 159, 159)
elseif DATA2 == "Soup" then
current = "Soup"
statLabel.TextColor3 = Color3.fromRGB(145, 73, 0)
elseif DATA2 == "Gruel" then
current = "Gruel"
statLabel.TextColor3 = Color3.fromRGB(66, 115, 2)
elseif DATA2 == "Cash" then
current = "Cash"
statLabel.TextColor3 = Color3.fromRGB(114, 255, 98)
end
statLabel.Text = EN.short(DataVal,2).." "..current
NewLBFrame.rank.Text = "#"..rank
--NewLBFrame.Position = UDim2.new(0, 0, NewLBFrame.Position.Y.Scale + (0.1 * #donationBoard.SurfaceGui.Holder:GetChildren()), 0)
NewLBFrame.Parent = LB.SurfaceGui.ScrollingFrame
if rank == 1 then
--NewLBFrame.playerName.TextColor3 = Color3.new(1, 0.705882, 0.227451)
NewLBFrame.rank.TextColor3 = Color3.new(1, 0.705882, 0.227451)
--NewLBFrame.Avatar.BackgroundColor3 = Color3.new(0.997803, 0.884443, 0.247959)
elseif rank == 2 then
--NewLBFrame.playerName.TextColor3 = Color3.new(0.721294, 0.721279, 0.721279)
NewLBFrame.rank.TextColor3 = Color3.new(0.721294, 0.721279, 0.721279)
--NewLBFrame.Avatar.BackgroundColor3 = Color3.new(0.721294, 0.721279, 0.721279)
elseif rank == 3 then
--NewLBFrame.playerName.TextColor3 = Color3.new(0.736507, 0.487678, 0.259174)
NewLBFrame.rank.TextColor3 = Color3.new(0.736507, 0.487678, 0.259174)
--NewLBFrame.Avatar.BackgroundColor3 = Color3.new(0.736507, 0.487678, 0.259174)
end
end
end
end)
if not success then
print(errorMessage)
end
end
while true do
for _, player in pairs(game.Players:GetPlayers()) do
local Top1 = player.Stats.Normal.Saffron
local Top2 = player.Stats.Normal.Truffle
local Top3 = player.Stats.Normal.Caviar
local Top4 = player.Stats.Normal.Gourmet
local Top5 = player.Stats.Normal.Cake
local Top6 = player.Stats.Normal.Cookies
local Top7 = player.Stats.Normal.Fork
local Top8 = player.Stats.Normal.Spoon
local Top9 = player.Stats.Normal.Soup
local Top10 = player.Stats.Normal.Gruel
local Top11 = player.Stats.Normal.Cash
local top = 0.0001
local top2 = nil
if EN.meeq(Top1.Value,top) then
top = Top1.Value
top2 = Top1.Name
elseif EN.meeq(Top2.Value,top) then
top = Top2.Value
top2 = Top2.Name
elseif EN.meeq(Top3.Value,top) then
top = Top3.Value
top2 = Top3.Name
elseif EN.meeq(Top4.Value,top) then
top = Top4.Value
top2 = Top4.Name
elseif EN.meeq(Top5.Value,top) then
top = Top5.Value
top2 = Top5.Name
elseif EN.meeq(Top6.Value,top) then
top = Top6.Value
top2 = Top6.Name
elseif EN.meeq(Top7.Value,top) then
top = Top7.Value
top2 = Top7.Name
elseif EN.meeq(Top8.Value,top) then
top = Top8.Value
top2 = Top8.Name
elseif EN.meeq(Top9.Value,top) then
top = Top9.Value
top2 = Top9.Name
elseif EN.meeq(Top10.Value,top) then
top = Top10.Value
top2 = Top10.Name
elseif EN.meeq(Top11.Value,top) then
top = Top11.Value
top2 = Top11.Name
end
top = EN.lbencode(top)
Top:SetAsync(player.UserId,top)
TOPTYPE:SetAsync(player.UserId,top2)
end
for _,frame in pairs(LB.SurfaceGui.ScrollingFrame:GetChildren()) do
if frame:IsA("Frame") then
frame:Destroy()
end
end
update()
wait(10)
end
Now of course not many people would know the first thing about leaderboards, especially best stat ones, but any help would be of use!