Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is it possible to insert a Shirt into a Player's model?

I started making a script like this:

game.Players.PlayerAdded:connect(function(player)
    if player.Name == "Player1" then
        player.CanLoadCharacterAppearance = false
        player.CharacterAdded:connect(function(char)
            local bodycolors = Instance.new("BodyColors", char)
	    local Shirt = Instance.new("Shirt", char)
            char.Head.face.Texture = "rbxassetid://28257733"
	    Shirt.Texture = "rbxassetid://284609852"
            bodycolors.RightArmColor = BrickColor.new("Pastel brown")
            bodycolors.LeftArmColor = BrickColor.new("Pastel brown")
            bodycolors.LeftLegColor = BrickColor.new("Dark stone grey")
            bodycolors.RightLegColor = BrickColor.new("Dark stone grey")
            bodycolors.TorsoColor = BrickColor.Random()
            bodycolors.HeadColor = BrickColor.new("Pastel brown")
        end)
    end
end)

But, it doesn't seem to work..

So, is it possible to insert a "Shirt" via an Instance.new ?

I also saw it was named "Clothing" in the player model, so i'm pretty confused right now.

Help needed!

1 answer

There are two ways to insert shirts:

  1. Via Instance.new

You can Instantiate a shirt and set it's texture. It seems that you have chosen this method, but it doesn't work. It's because Texture is not a valid member of shirt. It's actually ShirtTemplate to change the shirt's texture. With pants it could be PantsTemplate

**Note:**When applying a texture to your clothing, the ID you've got from the catalog item does not work. You have to find the actual texture of the shirt.

Shirt.ShirtTemplate= "rbxassetid://284609852"

You also noticed that the name of the Instantiated shirt is "Clothing". "Clothing" is the default name of shirts and pants.

  1. Via InsertService

You can use the InsertService to insert a clothing from the catalog. Different from the Instance.new method, you use the catalog ID of the clothing, and not the actual texture.

--The asset id of the shirt
local assetId = 0212
--The InsertService
local insertService = game:GetService("InsertService")

--Insert the clothing
insertService:LoadAsset(assetId)

Note: When you insert anything using InsertService, the object you insert will come packed inside a Model. So you have to get the shirt inside the model and then place it in the character.

Also note: You CAN'T use InsertService via LocalScripts.

--The asset id of the shirt
local assetId = 0212
--The InsertService
local insertService = game:GetService("InsertService")

--Insert the clothing
local insertedClothing = insertService:LoadAsset(assetId)

local shirt

--Iterate through the inserted object's children
for _,child in pairs(insertedClothing:GetChildren()) do
	if child:IsA("Shirt") then
		shirt = child
	end
end

shirt.Parent = putYourCharacterHere

This discussion is preserved as it was. New answers, comments, and votes are closed.