How do I get the IDs of the shirt and pants worn on someone's avatar?

I’m working on a game where we have a uniform equipper proximity prompt, it sets the shirt and pants for a user.

If I wanted to create one that would set the user’s original clothes back, like taking off the uniform, how would I do this?

I’ve tried searching for it but found nothing.

1 Like

Are you planning to do this on Client or Server?

1 Like

If you’d want on Server, you can do this:

game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Shirt = Character:FindFirstChildWhichIsA("Shirt")
--and do the same for pants
end)
end)

Beware that this could return nil if there are no clothing, more shirts.

1 Like

Method #1:
Clone the player’s clothes into a folder or save the player’s clothes ID when a player joins the game, so you can retrieve it when needed.

Method #2: GetCharacterAppearanceInfoAsync
This will return a table with what the player is currently wearing:

local ShirtTable = game.Players:GetCharacterAppearanceInfoAsync(Player.UserId)
		for i, val in pairs(ShirtTable["assets"]) do
			if ShirtTable["assets"][i]["assetType"]["name"] == "Shirt" then
				local InstanceShirt = Instance.new("Shirt")
				InstanceShirt.Name = "Shirt"
				InstanceShirt.ShirtTemplate = InsertService:LoadAsset(ShirtTable["assets"][i]["id"]):GetChildren()[1].ShirtTemplate
				InstanceShirt.Parent = Character
			elseif ShirtTable["assets"][i]["assetType"]["name"] == "Pants" then		
				local InstanceShirt = Instance.new("Pants")
				InstanceShirt.Name = "Pants"
				InstanceShirt.PantsTemplate = InsertService:LoadAsset(ShirtTable["assets"][i]["id"]):GetChildren()[1].PantsTemplate
				InstanceShirt.Parent = Character
			end
		end
6 Likes

To add onto this, is there any way to just reset the clothing, as if you were resetting the player, but only with the clothing.

Depends. What do you mean by “reset”? You could store the original shirt and pants as a StringValue inside the Character.

local players = game:GetService("Players")

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local shirtId = character:WaitForChild("Shirt").ShirtTemplate
		local pantsId = character:WaitForChild("Pants").PantsTemplate
		local tShirtId = character:WaitForChild("Shirt Graphic").Graphic
	end)
end)

Just a slight modification, I’ve added the necessary stuff to get the ID for the shirt, pants & t-shirt of the player.

As in, is there a function similar to LoadPlayer but only for a specific item like a shirt or pants.