:GetChildren Doesn't Acknowledge Accessories

I have a simple problem. I am using :GetChildren to return a list of children to a character.
Specifically I am looking to find accessories.

Given that char is the variable to a character within a game.
When the line char:GetChildren() is ran a table of instances are returned.
None of which elements are accessories.

How come? And how do I find accesories otherwise?

I have tried :GetDescendants()

This is my script and goal:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		for _,v in pairs(char:GetChildren()) do
			if v:IsA("Accessory") then
				v:Destroy()
			end
		end
	end)
end)

My Goal is to remove accessories from players upon entering the game. Does there happen to be a better way of doing this?
Even if there is a better way of doing this, how come :GetChildren() doesn’t include all instances? It’s not just Accessories it excludes. I haven’t tested it, but I have noticed it skips out on some things. It just hasn’t become a problem until now.

I haven’t been coding for a while so I’m a little rusty and may have just overlooked something simple, but I’m unsure what else to do regarding :GetChildren() to return ALL children.

All the children (so what it should be returning):
image

What it returns instead:
image

3 Likes

It’s because CharacterAdded fires when the character of player is created but the clothing and accessories are not yet loaded.

To solve this, use CharacterAppearanceLoaded instead.

3 Likes

Thanks so much, that makes way more sense. Good to hear that the :GetChildren() method does work and I was just using it incorrectly.

2 Likes

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