Custom clothing via id bar

What do I wish to achieve? - I would like to make a custom clothing picker using ids. You put an id for a shirt or pair of pants and press go and it applies it to your character.

What is the issue? - What I get from players is clothing ids, but to put that id onto a player I need the texture id that’s associated with the piece of clothing.

What solutions have I tried? - Tried to use InsertService | Roblox Creator Documentation for the clothing but instead would insert a random model.

1 Like

It’s possible to use InsertService to load a shirt model. When an asset is inserted into a game using InsertService, it comes inside a model.

This function uses MarketplaceService to verify the requested asset is a shirt before it’s added to the game and InsertService to load the shirt model.

local InsertService = game:GetService("InsertService")
local MarketplaceService = game:GetService("MarketplaceService")

local function ApplyShirtToCharacter(Character: Instance, ShirtId: number)
	local Success, Result = pcall(function()
		local AssetType = MarketplaceService:GetProductInfo(ShirtId).AssetTypeId
		if AssetType == 11 then
			local InsertedModel = InsertService:LoadAsset(ShirtId)
			local ShirtModel = InsertedModel:GetChildren()[1]

			local CharacterShirt = Character:FindFirstChildWhichIsA("Shirt")
			if CharacterShirt then
				CharacterShirt:Destroy()
			end

			ShirtModel.Parent = Character
			InsertedModel:Destroy()

			return true
		else
			return false
		end
	end)

	if Success and Result then
		return true
	else
		return false
	end
end
1 Like

Unfortunately this will not work, as it will require a remote event to get from the client to the server.

1 Like

I don’t think this a problem that can’t be overcome, getting IDs already needs to send a request to the server.

Edit:

Yep! I thought you meant that it wouldn’t work at all. A remote function would work well in this situation.

Thats why you need a remote event.

1 Like

Yes, that would work too! (Limit)

1 Like