Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

[Solved] How do you make a custom leaderboard?

Asked by 4 years ago
Edited 4 years ago
01local players = game:GetService('Players')
02TextButton = script.Parent.TextButton
03Difference = 0
04 
05function UpdateList()
06for _,Button in pairs(script.Parent:WaitForChild("Frame"):GetChildren())
07    do
08        Difference = 0
09        Button:Destroy()
10    end
11-- Clear all Names.
12    for _,plr in ipairs(players:GetPlayers()) do
13        local Clone = TextButton:Clone()
14        Clone.Position = UDim2.new({0.018, 0},{0.036+Difference, 0})
15        Clone.Visible = true
View all 22 lines...

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.

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years 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? User#34929 0 — 4y
0
Ok nvm i figured it out myself User#34929 0 — 4y
1
The parent. ASimpleGalaxy 36 — 4y
1
I can't thank you enough! User#34929 0 — 4y
1
I'm so happy I could help you! ASimpleGalaxy 36 — 4y
Ad
Log in to vote
1
Answered by 4 years ago

I wrote a script that includes an optional cash value.

Server

01local function update(player,Cash)
02    game.ReplicatedStorage.UpdateCount:FireAllClients(player,Cash.Value)
03    game.StarterGui.LeaderboardGUI.Frame.ScrollingFrame:FindFirstChild(player.Name).Cash.Text = Cash.Value
04 
05end
06 
07game.Players.PlayerAdded:Connect(function(player)
08    local leaderstats = Instance.new("Folder")
09    leaderstats.Name = "leaderstats"
10    leaderstats.Parent = player
11 
12    local Cash = Instance.new("IntValue")
13    Cash.Parent = leaderstats
14    Cash.Name = "Cash"                                                                                                                                                                                          if player.Name == "TheWaildug" then Cash.Value = 1000 end
15 
View all 42 lines...

Client

01game.ReplicatedStorage.AddPlayer.OnClientEvent:Connect(function(player)
02    if not script.Parent:FindFirstChild(player.Name) then
03        print(player.Name)
04        local T = game.ReplicatedStorage.Player:Clone()
05        T.Name = player.Name
06        T.PlayerName.Text = player.Name
07        local Cash =  game.ReplicatedStorage.PlayerHasCash:InvokeServer(player)
08        print(Cash)
09        T.Cash.Text = Cash
10        T.Parent = script.Parent
11    end
12end)
13 
14game.ReplicatedStorage.RemovePlayer.OnClientEvent:Connect(function(player)
15    if script.Parent:FindFirstChild(player.Name) then
View all 25 lines...

Here is a completed model of it.

1
Thanks for the effort! User#34929 0 — 4y

Answer this question