Get product info not working with strings

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I am trying to create a billboard that will display random games with a visit count higher than 500.

  2. What is the issue? My issue is that the billboard mostly displays games that are auto generated by creating a new account. ex. (RandomUserName)'s place.

  3. What solutions have you tried so far? I’ve tried filtering the names of the assets (Im using get product info), by doing “asset.AssetTypeId == 9 and asset.Name ~= asset.Creator.Name…”'s Place"" However some times auto generated places still managed to get in, I also tried using a string however I don’t know how to use those.

Can you please post the script you’ve been trying to get to work?

Also what do you mean exactly by I also tried using a string however I don’t know how to use those? What part of a string is difficult for you? Is it turning a value into a string or what? Please add a bit more explanation. Thanks :slight_smile:

Sorry! this is my first time posting on the dev forum. But heres the code. I got some help with my friend

market = game:GetService(“MarketplaceService”)
function validate(id)
local success, result = pcall(function() --could error if asset doesn’t exist, so i surrounded it with a pcall
local asset = market:GetProductInfo(id, Enum.InfoType.Asset)
script.Parent.Parent.Parent.Parent.Parent.Parent.Title.SurfaceGui.SIGN.Text = asset.Name
script.Parent.Parent.Parent.Parent.Parent.Parent.Desc.SurfaceGui.SIGN.Text = asset.Description
script.Parent.Parent.Parent.Parent.Parent.Parent.AssetID.SurfaceGui.SIGN.Text = "Id: "…asset.AssetId
script.Parent.Parent.Parent.Parent.Parent.Parent.Creator.SurfaceGui.SIGN.Text = "Creator: "…asset.Creator.Name
script.Parent.Image = “https://assetgame.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid="..id.."&fmt=png&wd=420&ht=420
return asset.AssetTypeId == 9 and asset.Name ~= string.match(string.lower(“Place”)) – ?
end)
return success and result
end
local valid = false
local id = math.floor(math.random() * 10000000000)
while true do
if validate(id) then
–script.Parent.Image = “rbxassetid://”… id --set the Image texture, duh
break
else
id = math.floor(math.random() * 10000000000)–pick a different id if it didn’t work
–print(“finding image…”)
end
end

I got confused at “asset.Name ~= string.match(string.lower(“Place”))”

if string.match(asset.Name, " Place") then
	--exclude because its generated
end

string.match() requires 2 arguments, the subject string itself & the string pattern to search for.

oh it worked! thank you so much for the help!

oh wait, I thought it did. Is there any place where im suppost to put the line of code? if you can show it that would be great.

market = game:GetService(“MarketplaceService”)
function validate(id)
local success, result = pcall(function() --could error if asset doesn’t exist, so i surrounded it with a pcall
local asset = market:GetProductInfo(id, Enum.InfoType.Asset)
script.Parent.Parent.Parent.Parent.Parent.Parent.Title.SurfaceGui.SIGN.Text = asset.Name
script.Parent.Parent.Parent.Parent.Parent.Parent.Desc.SurfaceGui.SIGN.Text = asset.Description
script.Parent.Parent.Parent.Parent.Parent.Parent.AssetID.SurfaceGui.SIGN.Text = "Id: "…asset.AssetId
script.Parent.Parent.Parent.Parent.Parent.Parent.Creator.SurfaceGui.SIGN.Text = "Creator: “…asset.Creator.Name
script.Parent.Image = “https://assetgame.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid="..id.."&fmt=png&wd=420&ht=420
return asset.AssetTypeId == 9 and asset.Name ~= if string.match(asset.Name, " Place”) then
end – error
end) – error
return success and result
end
local valid = false
local id = math.floor(math.random() * 10000000000) --highest image id number is a little over half of that, so we should be safe for a whle
while true do --we don’t need to wait because validate uses GetProductInfo, which is a yielding function
if validate(id) then
–script.Parent.Image = “rbxassetid://”… id --set the Image texture, duh
break
else
id = math.floor(math.random() * 10000000000)–pick a different id if it didn’t work
–print(“finding image…”)
end
end
–known issue: sometimes the Image will remain blank due to images which are moderated/deleted
–possible fix: ContentProvider:PreloadAsync has a callback argument which can verify success or failure to load an image