Accessory Remover not detecting Accessories

Hello,
I have a problem with my accessory removing script.

It does not detect accessories (or at least the “DOGE” one)

I tried making it check for the handle and check if it is not a tool. Didn’t work.

The script is a script in SSS (ServerScriptService). Its for giving the player custom clothes, tools, accessories etc. if they are on a team.

for i, child in pairs(char:GetChildren()) do
	if child:IsA("Accessory") then
		child:Destroy()
	end
end

Thanks if you can help.

When does this script run? Is it connected to CharacterAdded event?

Indeed, the first 2 lines are:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)

Then it’s probably not working because the code is running before game adds the accessories to player’s character. Try to change CharacterAdded event with CharacterAppearanceLoaded event.

It didn’t work.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(function(char)

Try:

for i, child in pairs(char:GetDescendants()) do
	if child:IsA("Accessory") then
		child:Destroy()
	end
end```

You could try

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAppearanceLoaded:Connect(function(char) 
		local hum = char:FindFirstChild("Humanoid") 
		hum:RemoveAccessories() 
	end) 
end) 

Sorce: Modified from the developer hub example here

Both slothfulGuy’s and TwyPlasma’s solutions worked, thanks alot.

Some accessories may display as Hats you might want to also look out for the “Hat” class. It is deprecated and by default all catalog items are converted to accessories but if you use any models from the toolbox they may still appear as Hats.

Alternatively, sometimes accessories can take a while to load. It’s not like they exist when Character is added.

Consider adding a wait and see if that resolves your problem.

1 Like

Thank you soo much, you help me a lot