How to get the name of an asset by assettypeId?

The reason I dont do this is because the AssetType in the list I’m using is a number. If i run your code it will just do this:

clone.Image = "rbxthumb://type=GameIcon&id="..v.Item.AssetId .."&w=420&h=420"

or

clone.Image = "rbxthumb://type=GameThumbnail&id="..v.Item.AssetId .."&w=420&h=420"

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
image

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

What are you trying to use this for? there might be an easier solution.

I’m looping through a players favorites and I’m creating an image label for each favorite. I’m then setting the image of the image to the favorited item that’s currently being looped. I already have a list of their favorites the problem is just setting the image to be that favorited item’s image


It still resulted in this. Maybe rbxthumb://type= doesnt work with assettypeid or something?

could you try printing this?

function getAssetType(assettype)
	for i, v in ipairs(Enum.AssetType:GetEnumItems()) do
		if assettype == v.Value then
			return v.Name
		end
	end
end

---later again

print(getAssetType(v.Item.AssetType))

Oh hold on, hold on, I see the problem. AssetType also contains other things other than just what we wanted.

What other information does it give? I printed it and it gave me a valid name

https://developer.roblox.com/en-us/api-reference/enum/AssetType

Alright, just to make sure, you have tried this right?

clone.Image = v.Thumbnail.Url

Actually, I realize your problem now that I looked at the item closer. The problem is that you are trying to get the thumbnail to an AUDIO, which doesn’t have a thumbnail. So, what I provided earlier

should actually work fine. The only problem is that you would need to check whether or not you need a thumbnail for the item to be shown.

I don’t get their favorite audios. None of the images worked however the clone pops up

Are there any errors in the console?

there are none. I believe the issue is that (I THINK) assettype’s and rbxthumb://type= dont work the same way. I might have to make a dictionary if so

Well, you could also just use this I believe:

clone.Image = "rbxassetid://"..v.Item.AssetId

Now, I’m not sure if this works with games, so you will have to test that

It does the same thing as rbxthumb://type= which is REALLY weird… I don’t know whats going on

No errors just this:
image

How about

clone.Image = "asset-thumbnail/imageassetId="..v.Item.AssetId.."&width=420&height=420"

This is a REALLY old way, so I wouldn’t be surprised if it didn’t work tbh

It has the same results as the other ones. Something I want to note is that the image was stuff like: rbxasset://textures/ui/GuiImagePlaceholder.png

You need to map the ‘AssetType’ field of each asset to a corresponding ‘rbxthumb’ type.

2 Likes

Firstly you would get the ID of the asset and Second you would use Roblox’s Market Asset API to get the name of the asset. https://api.roblox.com/Marketplace/ProductInfo?assetId=000000. You would also use the GetProductInfo Function for this. This is just a short summary on how to do it.