Still have questions? Join our Discord server and get real time help.
Log in to vote

Custom Player List - update all users?

Asked by 2 years ago
Edited 2 years ago


I have a custom player list, and the custom player list will display a player's: Avatar, Name, Round Kills, and Killstreak. Only problem is, it doesn't update the Round Kills/Killstreak for the correct user in real time.

Example: Player 1 has 2 RoundKills and a Killstreak of 2. On Player 1's Display, it shows these stats belonging to Player 2 instead of the actual player. How do I fix this? I know I need it to check for all the players, but I'm not sure how to do that correctly, my prior attempts have failed.

In my Leaderstats script I have this bit of code:

local updatedPlayerKillstreak = game:GetService("ReplicatedStorage"):WaitForChild("KillStreakUpdate")
game:GetService("ReplicatedStorage"):WaitForChild("KillStreakUpdate"):FireClient(Player, updatedPlayerKillstreak, Killstreak.Value)
print("Killstreak check")

local updatedPlayerKills = game:GetService("ReplicatedStorage"):WaitForChild("KillUpdate")
game:GetService("ReplicatedStorage"):WaitForChild("KillUpdate"):FireClient(Player, updatedPlayerKills, Roundkills.Value)
print("RoundKills check")

And under StarterGui I have my ScreenGui named "PlayerList" and a Local Script under that named "Main", this is the script below:

game.StarterGui:SetCoreGuiEnabled("PlayerList", false)
local plr = game.Players.LocalPlayer
local kills = plr.leaderstats.Roundkills.Value
local killstreak = plr.leaderstats.Killstreak.Value
local Avatarurl = ""
local gui = script.Parent

while wait(1) do

    for _,plr in pairs (game.Players:GetChildren()) do
        if script.Parent.Holder:FindFirstChild(plr.Name) then

            local kills2 = plr.leaderstats.Roundkills.Value
            local killstreak2 = plr.leaderstats.Killstreak.Value
            I ="Frame")
            I.Name = plr.Name
            I.Parent = script.Parent.Holder
            I.Style = "DropShadow"
-- NAME        
            T ="TextLabel")
            T.Name = "Username"
            T.BackgroundTransparency = 1
            T.Text = plr.Name
            T.Parent = I
            T.Size =, 165, 0, 35)
            T.Position =, 10, 0, 0)
            if plr.Name == game.Players.LocalPlayer.Name then
                T.TextColor3 = Color3.fromRGB(0, 200, 255)
            T.TextColor3 =, 1, 1)
            T.TextStrokeColor3 =, 0, 0)
            T.TextStrokeTransparency = 0.5
            T.TextXAlignment = "Left"
            T.Font = "SourceSansBold"
            T.TextSize = 20
-- KILLS           
            K ="TextLabel")
            K.Name = "RoundKills"
            K.BackgroundTransparency = 1
            K.Text = kills2     
            K.Parent = I
            K.Size =, 20, 0, 35)
            K.Position =, 155, 0, 0)
            K.TextColor3 =, 1, 1)
                K.TextStrokeColor3 =, 0, 0)
                K.TextStrokeTransparency = 0.5
                K.TextXAlignment = "Right"
                K.Font = "SourceSansBold"
                K.TextSize = 20

            KS ="TextLabel")
            KS.Name = "KillStreak"
            KS.BackgroundTransparency = 1
            KS.Text = killstreak2
            KS.Parent = I
            KS.Size =, 20, 0, 35)
            KS.Position =, 167, 0, 0)
            KS.TextColor3 =,0,0)
                KS.TextStrokeColor3 =, 0, 0)
                KS.TextStrokeTransparency = 0.5
                KS.TextXAlignment = "Right"
                KS.Font = "SourceSansBold"
                KS.TextSize = 20

            P ="ImageLabel")
            P.ScaleType = "Slice"
            P.Name = "AvatarImage"
            P.BackgroundTransparency = 1
            P.Image = Avatarurl..plr.Name
            P.Parent = I
            P.Size =,0,1.25,0)
            P.Position =, 0, 0, 0)

game:GetService("ReplicatedStorage"):WaitForChild("KillUpdate").OnClientEvent:Connect(function(updatedPlayerKills, value) 
    if(updatedPlayerKills.Name == plr.Name) then K.Text = value 

game:GetService("ReplicatedStorage"):WaitForChild("KillStreakUpdate").OnClientEvent:Connect(function(updatedPlayerKillstreak, value) 
    if(updatedPlayerKillstreak.Name == plr.Name) then KS.Text = value 


1 answer

Log in to vote
Answered by
Nonaz_jr 439 Moderation Voter
2 years ago
Edited 2 years ago

first off, you do this every second? making a whole new unupdated gui (using values read at initialization, such as killstreak, then waiting for the event to update it? I may misunderstand, I read it quickly.

Without the while loop, it's decent but it doesn't know which player to update: The event sends only a new value, but not the player to whom it applies. You should have it send a second argument, indicating which stat to update in the gui:

game:GetService("ReplicatedStorage"):WaitForChild("KillStreakUpdate").OnClientEvent:Connect(function(updatedPlayer, value)
    if(updatedPlayer.Name == plr.Name) then
        KS.Text = value

And of course the same for the killupdate, and also update the remote event code:

local updatedPlayer = <a way to know which player's killstreak was changed> game:GetService("ReplicatedStorage"):WaitForChild("KillStreakUpdate"):FireClient(Player, updatedPlayer, Killstreak.Value)

Edit: added code block

Edit 2: The changed code you asked:

--event script:
game:GetService("ReplicatedStorage"):WaitForChild("KillStreakUpdate"):FireAllClients(Player.Name, Killstreak.Value)
game:GetService("ReplicatedStorage"):WaitForChild("KillStreakUpdate").OnClientEvent:Connect(function(updatedPlayerName, value)
    if(updatedPlayerName == plr.Name) then --<removed the dot!
        KS.Text = value
o.o This looks good, but a tad confusing, can you put your script in the LUA block code so I can be sure I have it correct. Mainly, the last bit of code you did is popping up with errors, you didn't establish what local updatedPlayer is. Unless I'm misunderstanding. Thank you for your response btw!! :D Never2Humble 81 — 2y
So as you see in line 1 of the 2nd script there is "local updatedPlayer = <a way to know which player's killstreak was changed>": here you must add a bit of code of yourself to get the player whose killstreak etc must be updated Nonaz_jr 439 — 2y
^ I updated my main post with the edits, but its still not updating the stats in real time for the player list. Never2Humble 81 — 2y
So if this "Roundkills" in Roundkills.Changed:Connect(function() is a leaderstat numbervalue, it should not be so hard to find a reference to the player, who is leaderstats.Parent Nonaz_jr 439 — 2y
View all comments (3 more)
I don't see the problem right now. In any case, you should comment out line 2,3,4 of your localscript cause it's confusing, and try not to use the same variable name twice. it should use the right one here though Nonaz_jr 439 — 2y
it seems to me that the different players' stats are all in the same place in your gui (i.e. overlapping): I.Position =, 0, 0, nrOfButtons*buttonSizePlusOffset); nrOfButtons +=1 etc Nonaz_jr 439 — 2y
and make sure that the event firing is properly connected to the changing of the numbervalue in leaderstats, by the part of the script you didnt show, and confirm that this numbervalue is indeed changed in your tests. is the new value passed to localscript? Good luck! Nonaz_jr 439 — 2y

Answer this question