This script is supposed to put all the players in order so that the player with the most points will win!
local getScores = game.ReplicatedStorage.Scores:GetChildren()
local ScoreFolder = game.ReplicatedStorage.Scores
local Scores = {}
-- Organizing Procedure
for i = 1, #getScores do
table.insert(Scores, getScores[i].Value)
end
table.sort(getScores, function(a, b)
return b.Value < a.Value
end)
table.sort(Scores, function(a, b)
return b > a
end)
for i = 1, math.floor(#Scores/2) do
local j = #Scores - i + 1
Scores[i], Scores[j] = Scores[j], Scores[i]
end
-- Print
for i = 1, #Scores do
print(getScores[table.find(Scores, Scores[i])].Name .. " placed " .. i .. " with " .. Scores[i] .. "Points")
Scores[i].Value = 0
end
-- Reset Scores prrcedure
for i = 1, #getScores do
getScores[i]:Destroy()
end
It works so far but there is one problem, it will print only once and then print an error
07:55:06.636 - ServerScriptService.RoundHandler:154: attempt to index number with 'Value'

1 comment
You dont need to need Value at the end of scores. As I understand, scores is a table containing the player's scores, so just remover value