Custom playerlist including advanced information

Hi there, I’ve been trying to make a custom playerlist including the player’s names, avatars, teams and make another TextLabel visible if the player has a certain group rank.

This is my code:

local PlayerList = script.Parent
local Template = script.Parent.playername

function clearList()
	for _, item in pairs(PlayerList:GetChildren()) do
		if item:IsA("Frame") then
			item:Destroy()
		end
	end
end

function fillList()
	clearList()
	for _, player in pairs(game.Players:GetChildren()) do
		if not PlayerList:FindFirstChild(player.Name) then
			local frame = Template:Clone()
			frame.Name = player.Name
			
			frame.Username.Text = player.Name
			frame.Team.Text = player.Team

			if player:GetRankInGroup(5702291) >= 246 then
				frame.Staff.Visible = true
			end
			if player:GetRankInGroup(5702291) >= 250 then
				frame.Moderator.Visible = true
			end

			local userId = player.UserId
			local thumbType = Enum.ThumbnailType.HeadShot
			local thumbSize = Enum.ThumbnailSize.Size60x60
			local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)

			frame.Avatar.Image = content
			frame.Visible = true
			frame.Parent = PlayerList
		end
	end
end

fillList()

while wait(1) do
	fillList()
end

However, I’m getting the error:

To make it more clear, here are some pictures of the structure:


How’d I fix that error? Thanks in advance!

Hey there! So if I am reading this correctly, when you are clearing your list you are also removing your template. I would recommend that instead of clearing the entire list you use the PlayerAdded event, and store the template somewhere else. If you want to refresh it every second you can also just check to see if the frame in your clear list function is not your template! Hope this helps you.

1 Like

Thanks, that seems to have fixed it! Happy cakeday!