How would you filter out types of things other than games (example, remove shirts and try again)

I was curious on how someone would be able to “filter” roblox to just only games as a random game generator, not a random model or anything else.

Code:

local TeleportService = game:GetService("TeleportService")
local MarketplaceService = game:GetService("MarketplaceService")

while wait(10) do
	local rnger
	local PlaceID
	local success

	repeat
		rnger = math.random(100000, 1000000000)
		PlaceID = rnger

		success = pcall(function()
			return MarketplaceService:GetProductInfo(PlaceID)
		end)

		task.wait()
	until success

	local thumbnail = "https://assetgame.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid="..PlaceID .."&fmt=png&wd=420&ht=420"
	local surfacegui = script.Parent.Parent.Parent.SurfaceGui
	local Placename = MarketplaceService:GetProductInfo(PlaceID)

	surfacegui.Thumbnail.Image = thumbnail
	surfacegui.PlaceName.Text = Placename.Name

	script.Parent.MouseClick:Connect(function(player)
		TeleportService:Teleport(PlaceID, player)
	end)
end

You have to check for AssetTypeId:

local TeleportService = game:GetService("TeleportService")
local MarketplaceService = game:GetService("MarketplaceService")

local GetInfo = function(id)
	local PlaceID = id

	local thumbnail = "https://assetgame.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid="..PlaceID .."&fmt=png&wd=420&ht=420"
	local surfacegui = script.Parent.Parent.SurfaceGui
	local Info = MarketplaceService:GetProductInfo(PlaceID,Enum.InfoType.Asset)
	
	if Info.AssetTypeId == 9 then
		surfacegui.Thumbnail.Image = thumbnail
		surfacegui.PlaceName.Text = Info.Name
		return PlaceID
	end
end

local function GetRandomPlace()
	local rnger = math.random(100000, 2147483647) -- you CAN'T go any higher than this or it won't work
	local success, PlaceId = pcall(function()
		return GetInfo(rnger)
	end)

	if success and PlaceId then
		script.Parent.MouseClick:Connect(function(player)
			TeleportService:Teleport(PlaceId, player)
		end)
	else
		GetRandomPlace()
	end
end

while task.wait(10) do
	GetRandomPlace()
end
1 Like

It still shows models and shirts

Did you copy my exact code and use it? There should be no way it could still show models and shirts when the only asset with an AssetTypeId of 9 is a place.

Yeah, I used it, not sure what the problem is


Stuck on this

Paste your code and is there any errors? I just tested it on my end and no issues.

local TeleportService = game:GetService("TeleportService")
local MarketplaceService = game:GetService("MarketplaceService")

local GetInfo = function(id)
	local PlaceID = id

	local thumbnail = "https://assetgame.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid="..PlaceID .."&fmt=png&wd=420&ht=420"
	local surfacegui = script.Parent.Parent.SurfaceGui
	local Info = MarketplaceService:GetProductInfo(PlaceID,Enum.InfoType.Asset)

	if Info.AssetTypeId == 9 then
		surfacegui.Thumbnail.Image = thumbnail
		surfacegui.PlaceName.Text = Info.Name
		return PlaceID
	end
end

local function GetRandomPlace()
	local rnger = math.random(100000, 2147483647) -- you CAN'T go any higher than this or it won't work
	local success, PlaceId = pcall(function()
		return GetInfo(rnger)
	end)

	if success and PlaceId then
		script.Parent.MouseClick:Connect(function(player)
			TeleportService:Teleport(PlaceId, player)
		end)
	else
		GetRandomPlace()
	end
end

while task.wait(10) do
	GetRandomPlace()
end

It’s the exact same from the one you are using

Ah, I needed an extra “parent” at the surface variable

Aah… Haha, I was going to ask that next. Yeah, wasn’t sure if there was maybe any extra code that could’ve interrupted or caused issue. :slight_smile: Well, glad this helped!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.