Hello I currently am trying to give the player a specific shirt. Bassically the player enters a AssetID from the catalog and it gives that shirt.
here is my script
local function giveShirt(plr, id)
local char = plr.Character
if char:FindFirstChildOfClass("Shirt") then
warn("gave shirt")
char:FindFirstChildOfClass("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=" .. id
end
end
the issue is that the AssetId from the catalog is not the same assetID used on shirtTemplates and therefor it will not work. I dont know how to convert the assetid from catalog to shirttemplate id.
So how do I convert the assetid from catalog to shirttemplate id?
local HttpService = game:GetService(“HttpService”)
local assetId = 123456789 – Replace with your AssetId
local function convertAssetIdToShirtTemplateId(assetId)
local url = string.format(“https://api.roblox.com/asset-thumbnail/image?assetId=%d&width=1&height=1”, assetId)
local response = HttpService:GetAsync(url, false)
local decodedResponse = HttpService:JSONDecode(response)
return decodedResponse.ShirtTemplateId
end
local shirtTemplateId = convertAssetIdToShirtTemplateId(assetId)
print(“ShirtTemplateId:”, shirtTemplateId)
This will hopefully print you the shirttemplate id.