How to determine if an asset id is a Face or a Decal

I am trying to determine whether an asset ID that the user inputs is a Face ID from the catalog, or a texture ID from a decal (not the catalog ID as there’s no way to retrieve the texture ID from the catalog ID)

I thought of using the MarketplaceService:GetProductInfo() but there’s no way to determine if a player’s input is a texture ID or a catalog ID (for error catching).

In order to get the face’s ID, I use InsertService to get the ID from the Decal object that gets inserted. This method doesn’t work for decals however, as it throws an HTTP 403 (Forbidden) error.

I would like for one Textbox to automatically determine what type of ID needs to be processed, without having to ask the player if they are inserting a face ID or a decal’s texture ID.

You can try:
MarketPlaceService:GetProductInfo()

1 Like

Actually there is a way to detect if it’s an image or decal object with that function. The function returns a dictionary if an asset or developer product exist with the ID given. One of the values it returns is AssetTypeId which returns a number depending on the type of asset, (1 for image, 13 for decal, 18 for face, ect.). You can see the what does AssetTypeId numbers equals to in this page.

Here is an example:

local MarketPlaceService = game:GetService("MarketplaceService")
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterApperenceLoaded:Wait()

script.Parent.MouseButton1Click:Connect(function()
	local InputText = script.Parent.Parent.TextBox.Text
	local Success, ErrorMessage = pcall(function(AssetID)
		local ProductInfo = MarketPlaceService:GetProductInfo(tonumber(AssetID))
		if ProductInfo.AssetId == nil then
			print(AssetID.." is not a catalog AssetId.")
		else
			if ProductInfo.AssetTypeId == 1 then
				print("Image/Texture")
			elseif ProductInfo.AssetTypeId == 13 then
				print("Decal")
			elseif ProductInfo.AssetTypeId == 18 then
				print("Face")
			else
				print("Something Else")
			end
		end
	end, InputText)
	
	if Success == false then
		print(InputText.." is not a valid AssetId number.")
	end
end)
6 Likes

Thank you, I had no idea Face was an AssetType returned by GetProductInfo. What’s the difference between AssetType 1 (Image) and AssetType 13 (Decal)?

1 Like

Decal types are decal objects that you use in studio for applying image on baseparts with their Texture properties set to load an image type asset.

1 Like