Hello, I am trying to get the AssetType (string) from the AssetTypeId (number) of an object. Right now, I’m calling items by http service and It only gives me a AssetTypeId.
I’m trying to display an image of the object however the object can be any type of asset so i have to make Roblox determine it.
I’m looping through the table and I’m creating a new image label, then I’m setting the image to the assets image. Here’s my code:
for i,v in pairs(Suspected.Favorites) do
local clone = Results.All.Template:Clone()
clone.Parent = Results.All
clone.Image = "rbxthumb://type=Asset".. game:GetService("MarketplaceService").GetProductInfo(2).AssetType .."&id="..v.Item.AssetId .."&w=150&h=150"
end
(I didn’t actually know what I was doing and was going off of a google search when i said this:)
The method I’m using is universal however the name isnt.
I wanted to ask if it was possible to automatically detect the name of the assetype with the information I have of the product
Hey thanks for helping but like I said before, It has to be universal
maybe I wasn’t clear before: IM NOT JUST GETTING THEIR FAVORITE GAMES
I’m getting ALL their favorites (avatar items, games, etc)
Oh wait I’m seeing now, and I just realized that you weren’t the person I told that to previously to lol. Sorry if that came off as aggressive, It’s just I’m reexplaining it lol
Oh, yeah, that’s my bad. But, couldn’t you just get the assetType from the Enum AssetType list?
function getAssetType(assettype)
for i, v in ipairs(Enum.AssetType:GetEnumItems()) do
if assettype == v.Value then
return v.Name
end
end
end
--later in the code
clone.Image = "rbxthumb://type="..getAssetType(v.Item.AssetType).."&id="..v.Item.AssetId.."&w=420&h=420"
Also, it’s fine, I understand the pain of repeating yourself multiple times, typically worse for the same person lol