You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I am attempting to make my local scoreboard show the highest server based.
- What is the issue? Include screenshots / videos if possible!
It is not ranking correctly such as saying I am the highest while I have 0 and a second player has 100. I get no errors.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i have tried many sorting methods but none seem to fix my issue.
here is my code
Remotes.Events.UpdateScoreboard.OnClientEvent:Connect(function(playerCoinsTable, playerKillsTable, playerGoldTable, playerKillstreakTable)
for _,v in pairs(ScoreboardUI.Main.Coins:GetChildren()) do
if v:IsA("Frame") then
v:Destroy()
end
end
for _,v in pairs(ScoreboardUI.Main.Kills:GetChildren()) do
if v:IsA("Frame") then
v:Destroy()
end
end
for _,v in pairs(ScoreboardUI.Main.GoldBars:GetChildren()) do
if v:IsA("Frame") then
v:Destroy()
end
end
for _,v in pairs(ScoreboardUI.Main.Killstreak:GetChildren()) do
if v:IsA("Frame") then
v:Destroy()
end
end
table.sort(playerCoinsTable, function(a, b)
return a[2] > b[2]
end)
table.sort(playerKillsTable, function(a, b)
return a[2] > b[2]
end)
table.sort(playerGoldTable, function(a, b)
return a[2] > b[2]
end)
table.sort(playerKillstreakTable, function(a, b)
return a[2] > b[2]
end)
for _,v in pairs(playerCoinsTable) do
local CoinClone = ReplicatedStorage:WaitForChild("CoinTemplate"):Clone()
CoinClone.Parent = ScoreboardUI.Main.Coins
CoinClone.Amount.Text = Abbreviate(v[2])
CoinClone.NameLabel.Text = v[1]
local UserId = game.Players:GetUserIdFromNameAsync(v[1])
local content, isReady = game.Players:GetUserThumbnailAsync(UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
CoinClone.PlayerIcon.Image = content
end
for _,v in pairs(playerKillsTable) do
local KillsTemplate = ReplicatedStorage:WaitForChild("KillsTemplate"):Clone()
KillsTemplate.Parent = ScoreboardUI.Main.Kills
KillsTemplate.Amount.Text = Abbreviate(v[2]).." Kills"
KillsTemplate.NameLabel.Text = v[1]
local UserId = game.Players:GetUserIdFromNameAsync(v[1])
local content, isReady = game.Players:GetUserThumbnailAsync(UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
KillsTemplate.PlayerIcon.Image = content
end
for _,v in pairs(playerGoldTable) do
local GoldTemplate = ReplicatedStorage:WaitForChild("GoldTemplate"):Clone()
GoldTemplate.Parent = ScoreboardUI.Main.GoldBars
GoldTemplate.Amount.Text = Abbreviate(v[2])
GoldTemplate.NameLabel.Text = v[1]
local UserId = game.Players:GetUserIdFromNameAsync(v[1])
local content, isReady = game.Players:GetUserThumbnailAsync(UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
GoldTemplate.PlayerIcon.Image = content
end
for _,v in pairs(playerKillstreakTable) do
local StreakTemplate = ReplicatedStorage:WaitForChild("KillsTemplate"):Clone()
StreakTemplate.Parent = ScoreboardUI.Main.Killstreak
StreakTemplate.Amount.Text = Abbreviate(v[2]).." Kills"
StreakTemplate.NameLabel.Text = v[1]
local UserId = game.Players:GetUserIdFromNameAsync(v[1])
local content, isReady = game.Players:GetUserThumbnailAsync(UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
StreakTemplate.PlayerIcon.Image = content
end
end)