You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want to achieve a working custom player-list where it sorts players by the highest to lowest value
-
What is the issue?
-
What solutions have you tried so far? So far I have tried to name each player in alphabetical order as thats how the UIListLayout orders them.
local playervals = {}
for i,v in pairs(game.Players:GetPlayers()) do
if v.Values.Currencies:FindFirstChild("Bux") and v.Values.Currencies:FindFirstChild("RAP") then
table.insert(playervals, {Name = v.Name, UserId = v.UserId, DisplayName = v.DisplayName, Bux = v.Values.Currencies.Bux.Value, RAP = v.Values.Currencies.RAP.Value, VIP = v.Values.VIP.Value, Level = v.Values.Levels.Level.Value})
end
end
table.sort(playervals,
function(a,b)
return a.RAP>b.RAP
end
)
for i, v in pairs(playervals) do
if v then
local player = nil;
if findplrlist(v.Name) then
player = findplrlist(v.Name)
else
player = templates.Player:Clone()
end
if v.VIP then
player.Info.Username.TextColor3 = Color3.fromRGB(255, 207, 85)
else
player.Info.Username.TextColor3 = Color3.fromRGB(255, 255, 255)
end
if v.Name == game.Players.LocalPlayer.Name then
player.SendButton.Visible = false
end
player.Name = abcs[i] -- here is where it sets the name
player.Parent = UI.Playerlist.List
player.Info.Username.Text = v.DisplayName
player.Username.Value = v.Name
player.Info.Level.Text = v.Level
if lb == "RAP" then
player.Info.Value.Text = ab.abbreviate(v.RAP)
else
player.Info.Value.Text = "💵" .. ab.abbreviate(v.Bux)
end
end
end