how to check if an image ID or decal is valid in Roblox

Learn how to check if an Image ID or Decal ID is valid in Roblox using the MarketplaceService:GetProductInfo() function. Follow this example code.

To check if an Image ID or Decal ID is valid in Roblox, you can use the MarketplaceService:GetProductInfo() function. This function returns information about an asset, including its type. Here’s an example of how to use this function to check if a given ID is a valid decal:

local MarketplaceService = game:GetService("MarketplaceService")

local function isValidDecal(id)
    local success, info = pcall(MarketplaceService.GetProductInfo, MarketplaceService, id, Enum.InfoType.Asset)
    if success and info.AssetTypeId == 13 then
        return true
    else
        return false
    end
end

local decalId = 5365990751 -- Replace this with the ID you want to check
if isValidDecal(decalId) then
    print("Valid decal")
else
    print("Invalid decal")
end

In this example, replace decalId with the ID you want to check. The function isValidDecal will return true if the ID is a valid decal and false otherwise[1].

Citations:
[1] https://devforum.roblox.com/t/how-can-i-check-to-see-if-an-image-id-is-valid/1491213

By Perplexity at https://www.perplexity.ai/search/fb4c01ee-b6ac-4c68-a6d0-7f66ac3e1358

Scroll to Top