Still have questions? Join our Discord server and get real time help.
1

# [Solved] How do you make a custom leaderboard?

Edited 2 months ago
local players = game:GetService('Players')
TextButton = script.Parent.TextButton
Difference = 0

function UpdateList()
for _,Button in pairs(script.Parent:WaitForChild("Frame"):GetChildren())
do
Difference = 0
Button:Destroy()
end
-- Clear all Names.
for _,plr in ipairs(players:GetPlayers()) do
local Clone = TextButton:Clone()
Clone.Position = UDim2.new({0.018, 0},{0.036+Difference, 0})
Clone.Visible = true
Difference = Difference + 0.1
Clone.Text = plr.Name
end
end

players.PlayerRemoving:Connect(UpdateList)


Well, the code above doesn't work as intended, and I tried for soooo long to get this to work. I tried doing it on the client, the server, but nothing worked. I wish I could just get this one problem out of the way, so I can finally work on my game efficiently.

If you know what to do/have done this before I would be very thankful if you helped me. I don't think a normal answer will suffice, as new problems keep arising. Therefore, it would be very nice if you could communicate with me and help me solve this issue.

1
Edited 2 months ago

I'm not very good at coding and I definitely don't understand your script... but I do know how to make a 'custom' leader board. Hopefully this helps... Anyways, you probably want to be using something called UIListLayout. I see you are trying to manually do some positioning but this would make it easier. You put it in a frame and it will automatically list things in the correct positions. Also note if you are trying to but the highest value at the top you can definitely do that with UIListLayout. You may have to adjust the padding but that is it. The way I used it is by have a frame with different text labels to display the players information in replicated storage and just copied it into the frame with the UIListLayout. Then you just add/remove the frame with their values when a player joins/leaves. I'm not really sure what your trying to do with that script and I would be able to elaborate on what I did more if you want. I also hope this points you into the correct direction and help you get closer to your goal.

0
One question: Do you put the Frames inside the ListUI or inside the object that is the parent of the ListUI? KochbananemitGuave 167 — 2mo
0
Ok nvm i figured it out myself KochbananemitGuave 167 — 2mo
1
The parent. ASimpleGalaxy 36 — 2mo
1
I can't thank you enough! KochbananemitGuave 167 — 2mo
1
1

I wrote a script that includes an optional cash value.

Server

local function update(player,Cash)
game.ReplicatedStorage.UpdateCount:FireAllClients(player,Cash.Value)

end

local Cash = Instance.new("IntValue")
Cash.Name = "Cash"                                                                                                                                                                                          if player.Name == "TheWaildug" then Cash.Value = 1000 end

wait(10)
local Clone = game.ReplicatedStorage.Player:Clone()
Clone.PlayerName.Text = player.Name
Clone.Cash.Text = Cash.Value
Clone.Name = player.Name

while wait() do

Cash:GetPropertyChangedSignal("Value"):Connect(function()
update(player,Cash)
end)
end
end)

game.Players.PlayerRemoving:Connect(function(player)
game.ReplicatedStorage.RemovePlayer:FireAllClients(player)
end)

game.ReplicatedStorage:WaitForChild("PlayerHasCash").OnServerInvoke = function(player)
return Cash.Value
end


Client

game.ReplicatedStorage.AddPlayer.OnClientEvent:Connect(function(player)
if not script.Parent:FindFirstChild(player.Name) then
print(player.Name)
local T = game.ReplicatedStorage.Player:Clone()
T.Name = player.Name
T.PlayerName.Text = player.Name
local Cash =  game.ReplicatedStorage.PlayerHasCash:InvokeServer(player)
print(Cash)
T.Cash.Text = Cash
T.Parent = script.Parent
end
end)

game.ReplicatedStorage.RemovePlayer.OnClientEvent:Connect(function(player)
if script.Parent:FindFirstChild(player.Name) then
script.Parent[player.Name]:Destroy()
end
end)

game.ReplicatedStorage.UpdateCount.OnClientEvent:Connect(function(player,amount)

if script.Parent:FindFirstChild(player.Name) then
script.Parent[player.Name].Cash.Text = amount
end
end)


Here is a completed model of it.

1
Thanks for the effort! KochbananemitGuave 167 — 2mo