Why does custom Player List display not display everyone's stats, just the player's?
Hello!
I have a custom PlayerList. It adds players as they enter, removes them as they leave. It displays the player's avatar image, their name, their kills, and their kill streak. Unfortunately, it shows your kills/killstreaks for everyone, instead of displaying their unique kills/killstreaks.
How do I correct this to show each player's unique stats? The Name/Avatar Image shows the correct thing for each unique player, its just the stats from the Leaderstats that only show your info instead of each player's. I'm betting I've overlooked something simple here. ><
Not receiving any errors. Do I need to use WaitForChild() somewhere? If so, where?
Screen Gui - LocalScript:
01 | game.StarterGui:SetCoreGuiEnabled( "PlayerList" , false ) |
02 | local plr = game.Players.LocalPlayer |
03 | local kills = plr.leaderstats.Kills.Value |
04 | local killstreak = plr.leaderstats.Killstreak.Value |
08 | for _,plr in pairs (game.Players:GetChildren()) do |
09 | if script.Parent.Holder:FindFirstChild(plr.Name) then |
12 | I = Instance.new( "Frame" ) |
14 | I.Parent = script.Parent.Holder |
15 | I.Style = "DropShadow" |
18 | T = Instance.new( "TextLabel" ) |
19 | T.BackgroundTransparency = 1 |
22 | T.Size = UDim 2. new( 0 , 165 , 0 , 35 ) |
23 | T.Position = UDim 2. new( 0 , 10 , 0 , 0 ) |
24 | if plr.Name = = game.Players.LocalPlayer.Name then |
25 | T.TextColor 3 = Color 3. fromRGB( 0 , 200 , 255 ) |
27 | T.TextColor 3 = Color 3. new( 1 , 1 , 1 ) |
29 | T.TextStrokeColor 3 = Color 3. new( 0 , 0 , 0 ) |
30 | T.TextStrokeTransparency = 0.5 |
31 | T.TextXAlignment = "Left" |
32 | T.Font = "SourceSansBold" |
36 | K = Instance.new( "TextLabel" ) |
37 | K.BackgroundTransparency = 1 |
40 | K.Size = UDim 2. new( 0 , 165 , 0 , 35 ) |
41 | K.Position = UDim 2. new( 0 , 12 , 0 , 0 ) |
42 | K.TextColor 3 = Color 3. new( 1 , 1 , 1 ) |
43 | K.TextStrokeColor 3 = Color 3. new( 0 , 0 , 0 ) |
44 | K.TextStrokeTransparency = 0.5 |
45 | K.TextXAlignment = "Right" |
46 | K.Font = "SourceSansBold" |
50 | KS = Instance.new( "TextLabel" ) |
51 | KS.BackgroundTransparency = 1 |
54 | KS.Size = UDim 2. new( 0 , 165 , 0 , 35 ) |
55 | KS.Position = UDim 2. new( 0 , 21 , 0 , 0 ) |
56 | KS.TextColor 3 = Color 3. new( 255 , 0 , 0 ) |
57 | KS.TextStrokeColor 3 = Color 3. new( 0 , 0 , 0 ) |
58 | KS.TextStrokeTransparency = 0.5 |
59 | KS.TextXAlignment = "Right" |
60 | KS.Font = "SourceSansBold" |
65 | P = Instance.new( "ImageLabel" ) |
66 | P.BackgroundTransparency = 1 |
67 | P.Image = Avatarurl..plr.Name |
69 | P.Size = UDim 2. new( 1.25 , 0 , 1.25 , 0 ) |
70 | P.Position = UDim 2. new(- 1 , 0 , 0 , 0 ) |
And then the Screen Gui - Script:
1 | function playerleft(player) |
2 | if script.Parent.Holder:FindFirstChild(player.Name) then |
3 | script.Parent.Holder:FindFirstChild(player.Name):remove() |
6 | game.Players.ChildRemoved:connect(playerleft) |
Screenshots:
This one shows how the custom player list appears in the game where the Avatar/Name is unique, but the Kills/Streak is cloned:
https://ibb.co/h2QrtS
This one shows how the ScreenGui appears in PlayerGui during game play:
https://ibb.co/b7dcYS