So I made a custom leaderboard, it works and I want it to be in decending order, as its an obby game i want the player stage should be in decending order.
here is the script:
local uis = game:GetService("UserInputService")
local maxplayers = #game.Players:GetPlayers()
local newlist = Instance.new("UIListLayout",script.Parent)
newlist.Padding = UDim.new(0.05,0)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList,false)
local openpositiion = UDim2.new(0.842, 0,0.048, 0)
local canwork = true
uis.InputBegan:Connect(function(key,ischatting)
local success,errormessage = pcall(function()
if key.KeyCode == Enum.KeyCode.Tab and ischatting ~= true and canwork == true then
canwork = false
if script.Parent.Parent.Visible == true then
script.Parent.Parent:TweenPosition(UDim2.new(1.025, 0,0.048, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,1)
wait(1)
canwork = true
script.Parent.Parent.Visible = false
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("Frame") then
v:Destroy()
end
end
else
script.Parent.Parent.Visible = true
script.Parent.Parent:TweenPosition(openpositiion,Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,1)
script.Parent.CanvasSize = UDim2.new(0,0,math.ceil(maxplayers/7),0)
wait(0.5)
canwork = true
for i = 1,#game.Players:GetPlayers() do
wait(0.25)
local frame = Instance.new("Frame",script.Parent)
frame.Size = UDim2.new(1,0,script.Parent.CanvasSize.Y.Scale/6.666,0)
frame.BackgroundColor3 = Color3.new(0.184314, 0.184314, 0.184314)
frame.BorderMode = Enum.BorderMode.Inset
frame.BorderColor3 = Color3.new(0.290196, 0.290196, 0.290196)
frame.BorderSizePixel = 1
local textlabel = Instance.new("TextButton",frame)
textlabel.Size = UDim2.new(0.75,0,1,0)
textlabel.TextScaled = true
textlabel.Font = Enum.Font.PatrickHand
textlabel.BorderMode = Enum.BorderMode.Inset
textlabel.BackgroundTransparency = 5
textlabel.TextColor3 = Color3.new(1, 1, 1)
textlabel.Text = game.Players:GetPlayers()[i].DisplayName
textlabel.Name = game.Players:GetPlayers()[i].Name
local newlabel = Instance.new("TextLabel",frame)
newlabel.BackgroundTransparency = 5
newlabel.Font = Enum.Font.Nunito
newlabel.TextScaled = true
newlabel.TextColor3 = Color3.new(1, 1, 1)
newlabel.Text = game.Players:GetPlayers()[i].leaderstats.Stage.Value
newlabel.Size = UDim2.new(0.25,0,1,0)
newlabel.Position = UDim2.new(0.75,0,0,0)
textlabel.MouseButton1Click:Connect(function()
local newnewwwposition = UDim2.new(0.68, 0,0.165, 0)
local canwork = true
if script.Parent.Parent.Parent.SelectedPlayerFrame.Visible == true and canwork == true and textlabel.Text ~= game.Players.LocalPlayer.Name then
canwork = false
script.Parent.Parent.Parent.SelectedPlayerFrame:TweenPosition(UDim2.new(0.68, 0,-0.5, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,1)
wait(2)
canwork = true
script.Parent.Parent.Parent.SelectedPlayerFrame.Visible = false
elseif canwork == true and script.Parent.Parent.Parent.SelectedPlayerFrame.Visible == false and textlabel.Text ~= game.Players.LocalPlayer.Name then
script.Parent.Parent.Parent.SelectedPlayerFrame.Visible = true
canwork = false
script.Parent.Parent.Parent.SelectedPlayerFrame:TweenPosition(UDim2.new(0.68, 0,0.165, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,1)
wait(1)
canwork = true
script.Parent.Parent.Parent.SelectedPlayerFrame.SelectedPlayer.Value = textlabel.Name
end
end)
end
end
end
end)
end)
If you need the model for more reference here is the link:
Custom Leaderboard Model
please tell how to make it in order
btw its a obby stage so the stages option in leaderboard may appear error as leaderboard is not there in it