Need help completely removing layered clothing

I have a game which is about size changing, turning layeredclothing OFF in StarterPlayer cramps the clothes inside of the character to hide them, but since I can become small, they become visible when I shrink.
I haven’t been able to remove 3D clothes in any way.
i’ve come down to this script, which just removes all clothes 2D and 3D AND accessories, which is obviously wrong.
So I need help narrowing it down so this script only removes the 3D clothes.


function RemoveLayeredClothing(player)

	player.CharacterAdded:Connect(function(character)
	
		local function RemoveClothing()
		
			for _, item in pairs(character:GetChildren()) do
			
				if item:IsA("Shirt") or item:IsA("Pants") or item:IsA("Accessory") then
					item:Destroy()
				end
			end
		end

		
		RemoveClothing()

		
		character:WaitForChild("Humanoid").Changed:Connect(function()
			
			RemoveClothing()
		end)
	end)
end


game.Players.PlayerAdded:Connect(function(player)
	RemoveLayeredClothing(player)
end)
1 Like

Hi! Layered clothing is a accessory, and every accessory have AccessoryType property, so you can remove clothing based on this property.

--Code inside serverscript in ServerScriptService
local RemoveTable = {
	Enum.AccessoryType.Pants,
	Enum.AccessoryType.Shirt,
	Enum.AccessoryType.Jacket,
	Enum.AccessoryType.Sweater,
	Enum.AccessoryType.Shorts,
	Enum.AccessoryType.DressSkirt,
	Enum.AccessoryType.LeftShoe,
	Enum.AccessoryType.RightShoe,
	Enum.AccessoryType.TShirt,
	Enum.AccessoryType.Hat
}

game:GetService("Players").PlayerAdded:Connect(function(Player)
	Player.CharacterAppearanceLoaded:Connect(function(Character)
		for _, Clothes in Character:GetChildren() do
			if Clothes:IsA("Accessory") then
				if table.find(RemoveTable, Clothes.AccessoryType) then
					Clothes:Destroy()
				end
			end
		end
	end)
end)
3 Likes

Hello, thank you for your help. Unfortunately this happens:
image
this has always happened so I’m guessing something went wrong.

If i disable layeredclothing in starterplayer this happens:
image

this is also what always has happened when i disable that.

Hmm, this’s weird. Maybe RemoveTable doesn’t have accessory type of this clothing?
There’s some AccessoryTypes that i didn’t put into table

1 Like

Yea its definitaly a weird case. I’ve struggled with this ever since the release of 3D clothes and haven’t been able to fix it ever. I just left it in, but this is such an annoying part if a person is wearing it.

I agree with you

But i meant, maybe we just need to look into properties of this clothing and add into RemoveTable it’s AccessoryType?

1 Like

I think the properties you gave were right though, I’ve tried it before in this way, I just can’t get rid of layered clothes anymore in any way, even people that did succeed in it gave me their scripts and that also wouldn’t work

I have another idea. Does your script that you gave at the start removing clothing?

1 Like

This needs a pause after it, before the for loop, and isn’t them layered ones WrapLayer

for i,v in pairs(char:GetDescendants()) do
	if v:IsA("WrapLayer") then
		v.Parent.Parent:Destroy() --v.Handle.Accessory
	end
end

A layered clothing remover button

You could try removing all the layered accessories from the HumanoidDescription and then reapply it?

local players = game:GetService('Players')

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild('Humanoid', 30) :: Humanoid
		
		if not humanoid then
			return
		end
		
		local description = humanoid:GetAppliedDescription()
		
		local accessories = description:GetAccessories(true)
		
		for i = #accessories, 1, -1 do
			local accessoryInfo = accessories[i]
			
			if accessoryInfo and accessoryInfo.IsLayered then
				table.remove(accessories, i)
			end
		end
		
		description:SetAccessories(accessories, true)
		
		humanoid:ApplyDescription(description)
	end)
end)
1 Like

Yes, but it removes everything as in even classic clothing, accessories and so on

Tried it, but now nothing got removed at all

It’s working for me, can you send what you have? Make sure you’re reapplying the description at the end

1 Like
function RemoveLayeredClothing(player)

	player.CharacterAdded:Connect(function(character)

		local function RemoveClothing()

			for _, item in pairs(character:GetChildren()) do

				if item:IsA("Shirt") or item:IsA("Pants") or item:IsA("Accessory") then
					item:Destroy()
				end
			end
		end


		RemoveClothing()


		character:WaitForChild("Humanoid").Changed:Connect(function()

			RemoveClothing()
		end)
	end)
end

game.Players.PlayerAdded:Connect(function(player)
	RemoveLayeredClothing(player)
end)

local players = game:GetService('Players')

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild('Humanoid', 30) :: Humanoid

		if not humanoid then
			return
		end

		local description = humanoid:GetAppliedDescription()

		local accessories = description:GetAccessories(true)

		for i = #accessories, 1, -1 do
			local accessoryInfo = accessories[i]

			if accessoryInfo and accessoryInfo.IsLayered then
				table.remove(accessories, i)
			end
		end

		description:SetAccessories(accessories, true)

		humanoid:ApplyDescription(description)
	end)
end)

with this script it removes but doesn’t apply back.

Try removing the RemoveLayeredClothing function

1 Like

I did at first, without it nothing happens, nothing gets removed at all

I think we’re stuck.

Can you please show us how this clothes looks in explorer and it’s properties?
Also will be useful information about how this clothes appear in character

1 Like

I’ll get to this first thing tomorrow, which will be in about 8 hours, it’s past 1 am and I’m very tired, thanks for the help so far! :slight_smile:

Is this what you’re looking for?

local WhitelistAttribute = "Whitelisted" -- in case you ever wanna whitelist accessories

local Players = game:GetService("Players")

local function HandleChild(Accessory : Instance)
	if Accessory:IsA("Accessory") and Accessory:FindFirstChildWhichIsA("WrapLayer", true) and not Accessory:GetAttribute(WhitelistAttribute) then -- rather lazy way to check but it is what it is
		Accessory:Destroy()
		warn("Destroying:", Accessory:GetFullName())
	end
end

local function initchar(char : Model)
	local ChildAdded = char.ChildAdded:Connect(HandleChild)

	char.Destroying:Once(function()
		ChildAdded:Disconnect()
	end)

	char:GetPropertyChangedSignal("Parent"):Once(function()
		if not char.Parent then
			task.delay(5, char.Destroy, char) -- Roblox doesnt automatically destroy the character on removing so I'm just going to delay it by 5 so it wont break any other scripts
		end
	end)

	for i,v in char:GetChildren() do
		HandleChild(v)
	end
end

local function initplr(plr : Player)
	plr.CharacterAdded:Connect(initchar)
end

Players.PlayerAdded:Connect(initplr)
Players.PlayerRemoving:Connect(function(plr : Player)
	task.delay(5, plr.Destroy, plr) -- same reason above but in this case for Players
end)

for i,v in Players:GetPlayers() do
	initplr(v)

	if v.Character then
		initchar(v.Character)
	end
end
1 Like

You can also use HumanoidDescriptions to do this. Simple make a reference to the current applied HumanoidDescription of the Humanoid using Humanoid:GetAppliedDescription(), change the properties Shirt, Pants, and each Accessory type to 0, and use Humanoid:ApplyDescripton(HumanoidDescription) to apply the new changed HumanoidDescription.

1 Like