This would be an example of some code that would go into StarterCharacterScripts:
local Players = game:GetService("Players")
local baseUrl = "rbxassetid://"
local character = script.Parent
local player = Players:GetPlayerFromCharacter(character)
local humanoidDescription = Players:GetHumanoidDescriptionFromUserId(player.UserId)
local shirtId = humanoidDescription.Shirt
local newShirt = Instance.new("Shirt")
newShirt.ShirtTemplate = baseUrl..shirtId
newShirt.Parent = character
Generally #help-and-feedback:scripting-support is for help with scripting. If you’re looking for someone to code stuff for you, the talent hub is a good place for that.
If that code doesn’t work you can private message me and I can fix it
Oops! I didn’t realize what the HumanoidDescription.Shirt was. I thought it was the shirt texture ID, but it’s the catalog item ID.
This code should be fixed:
local Players = game:GetService("Players")
local InsertService = game:GetService("InsertService")
local character = script.Parent
local player = Players:GetPlayerFromCharacter(character)
local humanoidDescription = Players:GetHumanoidDescriptionFromUserId(player.UserId)
local shirtId = humanoidDescription.Shirt
local newShirt = InsertService:LoadAsset(shirtId):FindFirstChildOfClass("Shirt")
newShirt.Name = "Shirt"
newShirt.Parent = character
local players = game:GetService("Players")
local character = script.Parent
local player = players:GetPlayerFromCharacter(character)
local description = players:GetHumanoidDescriptionFromUserId(player.UserId)
local shirt = character:FindFirstChildOfClass("Shirt") or Instance.new("Shirt")
shirt.Name = "Shirt"
shirt.ShirtTemplate = "rbxassetid://"..description.Shirt
shirt.Parent = shirt.Parent or character
This would be arguably more performant, bare in mind the player’s character may already have a shirt equipped.
This is actually like what I had originally, but it didn’t work. The ShirtTemplate needs an image ID, while the HumanoidDescription.Shirt is the ID of the purchasable shirt in the catalog.
local players = game:GetService("Players")
local character = script.Parent
local player = players:GetPlayerFromCharacter(character)
local appearanceModel = players:GetCharacterAppearanceAsync(player.UserId)
local oldShirt = appearanceModel:FindFirstChildOfClass("Shirt")
if oldShirt then
local newShirt = character:FindFirstChildOfClass("Shirt") or Instance.new("Shirt")
newShirt.Name = "Shirt"
newShirt.ShirtTemplate = "rbxassetid://"..oldShirt.ShirtTemplate
newShirt.Parent = newShirt.Parent or character
end
appearanceModel:Destroy()