Client game.Players error that I can't figure out

I’m making a custom playerlist, and I’m getting an error on the client whenever someone leaves:

But the confusing part is this other player has nothing to do with what’s being referenced. It should only
concern the player referenced in the frame. I even added a check to make sure the “phantom player” wasn’t nil when they leave but it didn’t help.

Also, the code works completely fine upon a player joining and just while playing. Bizarrely, the error doesn’t even break the loop even though I didn’t make it a pcall or anything.

Here’s the code (note I’ve cut out all irrelevant portions):

local playerName = script.Parent.Name -- this is a textlabel where the name is the same as the player being referenced

local displayName = script.Parent.displayName --textlabel

while true do
	if script.Parent.Parent.Visible == true then
		if game.Players:FindFirstChild(playerName) then --error occurs here
			displayName.Text = " "..game.Players:FindFirstChild(playerName).DisplayName
            --more various information goes here (reason for it being in a loop)
		end
	end
	task.wait()
end

Can you please just double check that that is indeed the relevant script and code that is erroring? That error shouldn’t be occuring at all based on the code provided.

Right, it is the relevant script and code that is erroring. That’s why I’m so confused.

You can see in the error that dockedPlayerList.playerlist.PR_0B is the textlabel where the name is the same as the target

Am I right in assuming that this is a local script stored under a UI?

If you want and don’t mind sharing the rest of your code, it might be easier to diagnose the issue.

Solution: In the loop I checked to see if the player had any descendants before continuing in the loop. No idea why it fixed but it did.

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