Not a valid member error

i keep getting this error at this line in my script even tho the display name is a child of plrName: ty!
templateClone.displayName.Text = "@"..p.DisplayName
image
image

local template = script.Parent.plrScroll.plrName
local plrs = game:GetService("Players")

function updPlrs()

	local plr = game.Players.LocalPlayer
	local thumbnailtype = Enum.ThumbnailType.HeadShot
	local thumbnailsize = Enum.ThumbnailSize.Size420x420


for i, child in pairs(script.Parent.plrScroll:GetChildren()) do
	child:Destroy()
end

for i, p in pairs(game.Players:GetPlayers()) do
		local thumbnail = plrs:GetUserThumbnailAsync(p.UserId, thumbnailtype, thumbnailsize)

	local templateClone = template:Clone()

	templateClone.Parent = script.Parent.plrScroll
	templateClone.Visible = true
		templateClone.Text = p.Name
		templateClone.displayName.Text = "@"..p.DisplayName
		templateClone.PFP.Image = thumbnail

end
end

updPlrs()
game.Players.PlayerAdded:Connect(updPlrs)
game.Players.PlayerRemoving:Connect(updPlrs)
1 Like

Hi! I believe there are 2 things here that you might want to check. First, when we have indexes in a table, we need to use ‘ipairs’ method to look through the table. Second, check the individual PlayerGui when you load into the game, as the not a valid member error occurs in one of two cases:

  1. The gui has not loaded yet, which means we need to WaitForChild()
  2. The hierarchy is not called correctly, in which case check how the heirarchy is after you clone the gui and see if it matches what you are doing in the code.

I hope this helps!

2 Likes

hi again cal. :slight_smile:

thanks a million for your help, i accidentally figured it out prior to u messaging so mb but that info is very valuable. ill keep it in mind, cheers.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.