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)
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)
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 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
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)
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.
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
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
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.