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

Why does custom Player List display not display everyone's stats, just the player's?

Asked by 7 years ago

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:

01game.StarterGui:SetCoreGuiEnabled("PlayerList", false)
02local plr = game.Players.LocalPlayer
03local kills = plr.leaderstats.Kills.Value
04local killstreak = plr.leaderstats.Killstreak.Value
06 
07while wait(1) do
08    for _,plr in pairs (game.Players:GetChildren()) do
09        if script.Parent.Holder:FindFirstChild(plr.Name) then
10 
11        else
12            I = Instance.new("Frame")
13            I.Name = plr.Name
14            I.Parent = script.Parent.Holder
15            I.Style = "DropShadow"
View all 74 lines...

And then the Screen Gui - Script:

1function playerleft(player)
2    if script.Parent.Holder:FindFirstChild(player.Name) then
3        script.Parent.Holder:FindFirstChild(player.Name):remove()
4    end
5end
6game.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

0
Not sure how you'd change it to use the other players ones, but from what I can see it looks like you're using the localplayer's stats for every kill/streak. TairaAkiko 26 — 7y
0
:/ you're right. I'm just unsure how to get the other player's stats too. Never2Humble 90 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

the problem is your using the stats for the same player, how you would fix this is getting the stats for each player as you loop through them.

https://gyazo.com/011f344c332a36b8b0c47a9d8b82b996

heres the fixed script:

01game.StarterGui:SetCoreGuiEnabled("PlayerList", false)
02local plr = game.Players.LocalPlayer
03local kills = plr.leaderstats.Kills.Value
04local killstreak = plr.leaderstats.Killstreak.Value
06 
07while wait(1) do
08    for _,plr in pairs (game.Players:GetChildren()) do
09        if script.Parent.Holder:FindFirstChild(plr.Name) then
10 
11        else
12            local kills2 = plr.leaderstats.Kills.Value
13            local killstreak2 = plr.leaderstats.Killstreak.Value
14            I = Instance.new("Frame")
15            I.Name = plr.Name
View all 76 lines...
0
It worked perfectly!! Thank you!! :)! Never2Humble 90 — 7y
Ad

Answer this question