Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to list a player's accessories?

For some reason, when I use Character:GetChildren on a player's character, it does not get the accessories. How can I get the accessories from a player's character? This code prints out just about every child that is not an accessory. Why is GetChildren() omitting accessories?

Player.CharacterAdded:Connect(function(Char)
	local CharChildren = Char:GetChildren()
	for i, v in pairs(CharChildren) do
		print(CharChildren[i])
		if string.find(CharChildren[i].Name, "Doge") or string.find(CharChildren[i].Name, "doge") then
			CharChildren[i]:Destroy()
		end
	end
end)

I am basically trying to delete accessories that have the word "doge" in it, as I really hate doge and I am attempting for a trash free game.

1 answer

player = game.Players.LocalPlayer
character = player.Character

function deleteAccessories()
	for i,v in ipairs(character:GetChildren())do
		if(v:IsA("Accessory"))then
			print(v.Name)
		end
	end
end
wait()
deleteAccessories()

1 comment

0

Should also utilize ChildAdded on character for accessories that load after the script runs and make your variables local.

This discussion is preserved as it was. New answers, comments, and votes are closed.