Hey everyone this is a ranking system, it checks for the top 10 in the rankings and it displays their picture & name, their ranking value & it displays their team image behind their picture. Works but I'm sure it's extremely inefficient :( Could anyone improve this?
Rankings = game.StarterGui.UI.RankingsMenu
repeat wait() until _G.Overall:GetSortedAsync(false,10) ~= nil
local pages = _G.Overall:GetSortedAsync(false, 10)
local currentPageNumber = 0
while wait(0.1) do
local data = pages:GetCurrentPage()
for _, pair in ipairs(data) do
if Rankings.R1.TextLabel.Text == "PLAYER" then
username = game.Players:GetNameFromUserIdAsync(pair.key)
Rankings.R1.Overall.Text = pair.value .. " OVR"
Rankings.R1.TextLabel.Text = string.upper(username)
Rankings.R1.Player.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=200&Format=Png&username=" .. username
if _G.Team:GetAsync(pair.key)[4] ~= nil and _G.Team:GetAsync(pair.key)[4] ~= 0 then
Rankings.R1.Team.Image = "rbxassetid://" .. _G.Team:GetAsync(pair.key)[4]
end
elseif Rankings.R2.TextLabel.Text == "PLAYER" then
username = game.Players:GetNameFromUserIdAsync(pair.key)
Rankings.R2.Overall.Text = pair.value .. " OVR"
Rankings.R2.TextLabel.Text = string.upper(username)
Rankings.R2.Player.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=200&Format=Png&username=" .. username
if _G.Team:GetAsync(pair.key)[4] ~= nil and _G.Team:GetAsync(pair.key)[4] ~= 0 then
Rankings.R2.Team.Image = "rbxassetid://" .. _G.Team:GetAsync(pair.key)[4]
end
elseif Rankings.R3.TextLabel.Text == "PLAYER" then
username = game.Players:GetNameFromUserIdAsync(pair.key)
Rankings.R3.Overall.Text = pair.value .. " OVR"
Rankings.R3.TextLabel.Text = string.upper(username)
Rankings.R3.Player.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=200&Format=Png&username=" .. username
if _G.Team:GetAsync(pair.key)[4] ~= nil and _G.Team:GetAsync(pair.key)[4] ~= 0 then
Rankings.R3.Team.Image = "rbxassetid://" .. _G.Team:GetAsync(pair.key)[4]
end
elseif Rankings.R4.TextLabel.Text == "PLAYER" then
username = game.Players:GetNameFromUserIdAsync(pair.key)
Rankings.R4.Overall.Text = pair.value .. " OVR"
Rankings.R4.TextLabel.Text = string.upper(username)
Rankings.R4.Player.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=200&Format=Png&username=" .. username
if _G.Team:GetAsync(pair.key)[4] ~= nil and _G.Team:GetAsync(pair.key)[4] ~= 0 then
Rankings.R4.Team.Image = "rbxassetid://" .. _G.Team:GetAsync(pair.key)[4]
end
elseif Rankings.R5.TextLabel.Text == "PLAYER" then
username = game.Players:GetNameFromUserIdAsync(pair.key)
Rankings.R5.Overall.Text = pair.value .. " OVR"
Rankings.R5.TextLabel.Text = string.upper(username)
Rankings.R5.Player.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=200&Format=Png&username=" .. username
if _G.Team:GetAsync(pair.key)[4] ~= nil and _G.Team:GetAsync(pair.key)[4] ~= 0 then
Rankings.R5.Team.Image = "rbxassetid://" .. _G.Team:GetAsync(pair.key)[4]
end
elseif Rankings.R6.TextLabel.Text == "PLAYER" then
username = game.Players:GetNameFromUserIdAsync(pair.key)
Rankings.R6.Overall.Text = pair.value .. " OVR"
Rankings.R6.TextLabel.Text = string.upper(username)
Rankings.R6.Player.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=200&Format=Png&username=" .. username
if _G.Team:GetAsync(pair.key)[4] ~= nil and _G.Team:GetAsync(pair.key)[4] ~= 0 then
Rankings.R6.Team.Image = "rbxassetid://" .. _G.Team:GetAsync(pair.key)[4]
end
elseif Rankings.R7.TextLabel.Text == "PLAYER" then
username = game.Players:GetNameFromUserIdAsync(pair.key)
Rankings.R7.Overall.Text = pair.value .. " OVR"
Rankings.R7.TextLabel.Text = string.upper(username)
Rankings.R7.Player.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=200&Format=Png&username=" .. username
if _G.Team:GetAsync(pair.key)[4] ~= nil and _G.Team:GetAsync(pair.key)[4] ~= 0 then
Rankings.R7.Team.Image = "rbxassetid://" .. _G.Team:GetAsync(pair.key)[4]
end
elseif Rankings.R8.TextLabel.Text == "PLAYER" then
username = game.Players:GetNameFromUserIdAsync(pair.key)
Rankings.R8.Overall.Text = pair.value .. " OVR"
Rankings.R8.TextLabel.Text = string.upper(username)
Rankings.R8.Player.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=200&Format=Png&username=" .. username
if _G.Team:GetAsync(pair.key)[4] ~= nil and _G.Team:GetAsync(pair.key)[4] ~= 0 then
Rankings.R8.Team.Image = "rbxassetid://" .. _G.Team:GetAsync(pair.key)[4]
end
elseif Rankings.R9.TextLabel.Text == "PLAYER" then
username = game.Players:GetNameFromUserIdAsync(pair.key)
Rankings.R9.Overall.Text = pair.value .. " OVR"
Rankings.R9.TextLabel.Text = string.upper(username)
Rankings.R9.Player.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=200&Format=Png&username=" .. username
if _G.Team:GetAsync(pair.key)[4] ~= nil and _G.Team:GetAsync(pair.key)[4] ~= 0 then
Rankings.R9.Team.Image = "rbxassetid://" .. _G.Team:GetAsync(pair.key)[4]
end
elseif Rankings.R10.TextLabel.Text == "PLAYER" then
username = game.Players:GetNameFromUserIdAsync(pair.key)
Rankings.R10.Overall.Text = pair.value .. " OVR"
Rankings.R10.TextLabel.Text = string.upper(username)
Rankings.R10.Player.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=200&Format=Png&username=" .. username
if _G.Team:GetAsync(pair.key)[4] ~= nil and _G.Team:GetAsync(pair.key)[4] ~= 0 then
Rankings.R10.Team.Image = "rbxassetid://" .. _G.Team:GetAsync(pair.key)[4]
end
end
end
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
currentPageNumber = currentPageNumber + 1
end
script.Parent["[Pre-Load]Leaderboards"]:Destroy()

2 comments
I highly doubt anyone is going to read all of it and then post you a more efficient answer if it already works..
my gosh this hurts my eyes. please tab correctly.