GraphicTShirt in HumanoidDescription Can also set Classic Shirt and Pants

I’m making a game that has customization in it, and players must put in their own clothing ID.
My script is simply setting GraphicTShirt in HumanoidDescription to the given ID,
if player inserts an id of classic T-shirt from the catalog, it will make them wear it (simple).
but for some reason, players can aslo set their classic pants,and shirt through this, if they just input those Id’s instead, when it’s clearly supposed to be changing the T-SHIRT graphic.

I already searched for this question on the Forums, and didn’t find anything.

My code is very simple, something like this:

local humanoid = player.Character:FindFirstChild(“Humanoid”)
local description = humanoid:GetAppliedDescription()
description.GraphicTShirt = id --the given id by the player
humanoid:ApplyDescriptionReset(description)

Is there any way to solve this, or should i just try using a different method?
Can I do something like detect, if that’s a shirt or pants, and not a t-shirt?

You can use this thing called MarketplaceService!!!

Can prob use it like this:

local assetId = --wherever you get this
local info = MarketplaceService:GetProductInfo(assetId)
if info.AssetTypeId ~= 2 then --T-Shirt Id Type
    warn("nuh uh")
    return
end
1 Like

You can use Enum.AssetType to check whether the item is a classic shirt, t-shirt, or classic pants. If it doesn’t match the desired type, you can prevent it from being applied. An example script implementing this looks like the following:

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

local function applyTShirt(player, id)
    local humanoid = player.Character and player.Character:FindFirstChild("Humanoid")
    if not humanoid then
        warn("Humanoid not found!")
        return
    end

    -- Checking the item type via MarketplaceService
    local success, info = pcall(function()
        return MarketplaceService:GetProductInfo(id, Enum.InfoType.Asset)
    end)

    if success and info.AssetTypeId == Enum.AssetType.TShirt.Value then
        -- Apply GraphicTShirt if the type is correct
        local description = humanoid:GetAppliedDescription()
        description.GraphicTShirt = tostring(id)
        humanoid:ApplyDescriptionReset(description)
    else
        warn("The provided ID is not a valid T-Shirt ID!")
    end
end

-- Example of use:
local player = Players.LocalPlayer -- Replace with your player
local tShirtId = 123456789 -- Replace with T-shirt ID
applyTShirt(player, tShirtId)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.