How to correctly get a shirt/pants' texture ID

I have seen this so many times, a Roleplay game, the user types :pants me 123456 and lo and behold: the user gets a weird picture of a random Kpop star.

The problem is that admin command utilities creators almost never get the pants/shirt section correctly, it used to be that the texture of the pants/shirt/anything else was ASSETID-1, because Roblox has grown so much, assets are uploaded so quickly that it can range between -1 to -10! this means that once trying to get the asset itself from a user-defined number is much harder.


How do I solve this?

There is a very common misconception that you have to create a proxy, use some scary web-APIs just to get the texture-ID of an asset, but that is not the case! I am going to show you a very simple script to do it and elaborate on how it works.

The script

local AssetID = 607785314 -- https://www.roblox.com/catalog/607785314/ROBLOX-Jacket
local InsertService = game:GetService("InsertService")
local Asset = InsertService:LoadAsset(AssetID)
-- Now, the first child of Asset is the exact Shirt from the catalog id (http://www.roblox.com/asset/?id=607785311)

This can work with everything, and can also insert every asset to the game (that you own), including Plugins and Free Models.

So now it’s time to see if you ever used the old method of ASSET-1 and correct this mistake.

Hope I taught you something new
Goldy.

20 Likes

I might be wrong but I am pretty sure you can put the shirt or pants ID in settings so the players start with that.

1 Like

I don’t know if you can claim that this is “properly”.

HumanoidDescription exists for this and has more flexibility allowing you to load the character with a certain HumanoidDescription, or get the current description and modify it, for example swapping the pants ID, and then apply it again.

2 Likes

The thing is, it does not solve the original problem of getting the texture ID (that HumanoidDescription uses) from the website assetID

Example
local x = game.Players:GetHumanoidDescriptionFromUserId(174069834)
x.Shirt = "rbxassetid://174069834" -- The number from https://www.roblox.com/catalog/607785314/ROBLOX-Jacket
game.Players.GoldyyDev.Character.Humanoid:ApplyDescription(x)

will not place the correct asset as there is no TextureID for it to apply.

3 Likes

Yes, but I am talking about some games where you can’t do that in.

Then this is a tutorial of how to correctly get assets. Not how to properly apply shirt/pants.

Personally, I would rename the tutorial to adequately reflect the purpose so people know this is just about getting the asset ID, and that there are other methods for applying clothing assets to a player.

1 Like

I agree that it is a better topic name, I have renamed it to avoid confusion.

1 Like

I know this is an old topic, but I just want to say you can not do this from a LocalScript.

1 Like