Removing accessories not working

Server script in serverscriptservice

game.Players.PlayerAdded:Connect(function(plr)
	
	
	plr.CharacterAdded:Connect(function(char)
		
		--remove clothes
		for i, child in pairs(char:GetDescendants()) do
			if child:IsA("Shirt") or child:IsA("ShirtGraphic") or child:IsA("Pants") then
				child:Destroy()
			end
			
			
			
			--also, destroy any accessories that arent hair or hats
			if child:IsA("Accessory") then
				if child.AccessoryType ~= Enum.AccessoryType.Hat and child.AccessoryType ~= Enum.AccessoryType.Hair then
					child:Destroy()
				end
			end
		end
	end)
end)

My goal is to remove clothes (so I can add custom ones) as well as destroy any accessories that aren’t hats or hair.
This does not work. At all. I don’t know why, my only idea is that maybe it’s because the player hasn’t fully loaded in when it searches for accessories to destroy? If that is the case, how do I fix it? if it isn’t what do I do?

game.Players.PlayerAdded:Connect(function(plr)
	
	
	plr.CharacterAdded:Connect(function(char)
		
		repeat task.wait() until char.Humanoid -- Makes sure everything is loaded in.
		
		for i, child in pairs(char:GetDescendants()) do
			if child:IsA("Shirt") or child:IsA("ShirtGraphic") or child:IsA("Pants") then
				child:Destroy()
			end



			--also, destroy any accessories that arent hair or hats
			if child:IsA("Accessory") then
				if child.AccessoryType ~= Enum.AccessoryType.Hat and child.AccessoryType ~= Enum.AccessoryType.Hair then
					child:Destroy()
				end
			end
		end
	
	end)
end)

didnt work

character liiimittttttt

repeat wait() until plr:HasAppearanceLoaded() == true
1 Like

Oh yeah, didn’t think about that. Did it work?