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