Importing layered clothing via ID

Many games (including my own) utilize ID importers to allow players to customize their characters. Simply copy and paste a catalog ID for classic clothes or non-layered items and viola, the character is wearing them.
However, what I’ve really wanted to see and haven’t yet is an ID importer compatible with layered clothing.

I know a lot of big avatar customization games already have layered clothing support, but the freely-available importers and plugins still don’t support layered clothing.

Is there any way at all that a clothing ID importer can import layered clothing?

Right now, I’m using ewjadestinks’s editor, and here is its primary code:

if not workspace:FindFirstChild("AvatarEvent") then
	local event = Instance.new("RemoteEvent")
	event.Name = "AvatarEvent"
	event.Parent = workspace
end
local event = workspace.AvatarEvent
local insertS = game:GetService("InsertService")

event.OnServerEvent:Connect(function(player, id)
	local number = tonumber(id)
	if not number then return end
	local asset
	local char = player.Character
	local success = pcall(function()
		asset = insertS:LoadAsset(number)
	end)
	
	if not success then return end
	local child = asset:GetChildren()
	for _,v in pairs(child) do
		if v:IsA("Accessory") then
			char.Humanoid:AddAccessory(v)
		elseif v:IsA("Shirt") then
			local templ = v.ShirtTemplate
			char.Shirt.ShirtTemplate = templ
		elseif v:IsA("Pants") then
			local templ = v.PantsTemplate
			char.Pants.PantsTemplate = templ
		end
	end
	asset:Destroy()
end)

Since layered clothing is an extension of the ‘Accessory’ class you can insert the asset via InsertService:LoadAsset and then apply the accessory via Humanoid:AddAccessory.

1 Like

Then wouldn’t layered clothing work on ID importers like this by default then? Considering this line should make it work:

Because it doesn’t, I don’t think this’ll solve it…

local Game = game
local Players = Game:GetService("Players")
local InsertService = Game:GetService("InsertService")

local function OnPlayerAdded(Player)
	local function OnCharacterAdded(Character)
		local Success, Result = pcall(InsertService.LoadAsset, InsertService, 9112474888)
		if not Success then warn(Result) return end
		Result = Result:FindFirstChildOfClass("Accessory")
		if not Result then return end
		local Humanoid = Character:FindFirstChildOfClass("Humanoid") or Character:WaitForChild("Humanoid", 10)
		if not Humanoid then return end
		Humanoid:AddAccessory(Result)
	end
	
	Player.CharacterAdded:Connect(OnCharacterAdded)
end

Players.PlayerAdded:Connect(OnPlayerAdded)

As expected, this works for me.

1 Like

Oh, oddly it… does work on ID importers now. Strange it didn’t before. Ah well. Thanks anyway.