Setting a roblox players shirt

I am currently trying to make a script that sets a target players shirt to an ID set through a command, the command executes perfectly fine but I am finding the issue that the ID’s that people would use to set their shirts would be from the marketplace and those ID’s dont work when setting player shirts in studio? How would I go about getting the working studio ID’s from the catalog ID’s??

function onSetShirt(player, playerName, ID)
	local targetPlayer = Players:FindFirstChild(playerName)
	if targetPlayer and targetPlayer.Character then
		local humanoid = targetPlayer.Character:FindFirstChildOfClass("Humanoid")
		if humanoid then
			local success, errorMessage = pcall(function()
				local shirt = targetPlayer.Character:WaitForChild("Shirt")
				shirt.ShirtTemplate = ID
			end)

			if success then
				print(player.Name .. " set " .. playerName .. "'s shirt to " .. ID)
			else
				warn("Failed to set shirt for", playerName, ":", errorMessage)
			end
		else
			warn("Humanoid not found for player:", playerName)
		end
	else
		warn("Player not found:", playerName)
	end
end

You can, in Studio, insert your shirt’s ID in a Shirt instance. The ID will change to the shirt’s texture, that you can use in your purpose.

I figured it out, I used the InsertService to LoadAsset

1 Like