01 | local players = game:GetService( 'Players' ) |
02 | TextButton = script.Parent.TextButton |
03 | Difference = 0 |
04 |
05 | function UpdateList() |
06 | for _,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 = UDim 2. new( { 0.018 , 0 } , { 0.036 +Difference, 0 } ) |
15 | Clone.Visible = true |
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.
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.
I wrote a script that includes an optional cash value.
Server
01 | local 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 |
05 | end |
06 |
07 | game.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 |
Client
01 | game.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 |
12 | end ) |
13 |
14 | game.ReplicatedStorage.RemovePlayer.OnClientEvent:Connect( function (player) |
15 | if script.Parent:FindFirstChild(player.Name) then |
Here is a completed model of it.