Why don't the names re-position correctly in my custom leader-board?
I'm working on a custom leaderboard. Here's a snip of some of the code where it's supposed to sort the playername position based on their score.
01 | for h,q in pairs (script.Parent.LeaderBoard.Holder.players:GetChildren()) do |
02 | game.ReplicatedStorage:WaitForChild(q.Name) |
03 | q.Kills.Text = game.ReplicatedStorage:FindFirstChild(q.Name).currentrounddata.killsthisround.Value |
04 | q.Deaths.Text = game.ReplicatedStorage:FindFirstChild(q.Name).currentrounddata.deathsthisround.Value |
05 | table.insert(scores, q.Kills.text) |
06 | table.sort(scores, function (a,b) return a > b end ) |
07 | print ( 'starting player sort' ) |
09 | for i,v in pairs (scores) do |
11 | if v = = q.Kills.Text then print (q.Name) |
14 | local pos = i * . 06 + y |
15 | label.Parent = script.Parent.LeaderBoard.Holder.players |
16 | label.Position = UDim 2. new(. 5 , - 300 , pos, - 100 ) |
18 | print (i.. "Is over number of players! Error!" ) |
Below, it prints the output correctly. Ranking the scores through the table.
1 | table.insert(scores, q.Kills.text) |
2 | table.sort(scores, function (a,b) return a > b end ) |
3 | print ( 'starting player sort' ) |
5 | for i,v in pairs (scores) do |
But, in the block below it only prints one name(q.Name) and it only re-positions one name, causing an overlap.
1 | if v = = q.Kills.Text then print (q.Name) |
5 | label.Parent = script.Parent.LeaderBoard.Holder.players |
6 | label.Position = UDim 2. new(. 5 , - 300 , pos, - 100 ) |
Any help would be appreciated!