Im trying to get the price of a shirt so i tried using MarketPlaceService but it always returns nil
Whenever i just put in the id then it works fine
local ShirtInfo = game:GetService("MarketplaceService"):GetProductInfo(756245568)
print(ShirtInfo.PriceInRobux) -- 8
But when i try to get just a shirt id thats when the problem starts when i try to get the id from a shirt
local ShirtInfo = game:GetService("MarketplaceService"):GetProductInfo(tonumber(string.sub(CurrentItem.ShirtTemplate,14)) or tonumber(string.sub(CurrentItem.ShirtTemplate,33)))
print(ShirtInfo.PriceInRobux) -- returns nil
Try passing the Asset InfoType as the second argument.
local ShirtInfo = game:GetService("MarketplaceService"):GetProductInfo(tonumber(string.sub(CurrentItem.ShirtTemplate,14)) or tonumber(string.sub(CurrentItem.ShirtTemplate,Enum.InfoType.Asset)))
Roblox uploads two assets when you upload clothing: one is used to preview the asset as a item info page on the site and the other is the actually rendered texture. You can’t get a Shirt from a ShirtTemplate so you need to store both somewhere. Use the Shirt id when working with MarketplaceService features and the ShirtTemplate to render it via Shirt objects.
Also, protip for getting the ShirtTemplate id: this is a lot cleaner and arbitrary than sub: