Is there a way to do get a list of random games faster than what I have?

(moved to here from scripting support where I mistakenly posted it earlier)

Long story short, I’m looking to get the game icon and name of random games (a little over 1000 to be a bit more precise) to make a bunch of fake in game buttons of other games. It’s for the end of the game in which you appear to leave the game itself and wind up on top of the icon of the game that you’re playing, from where you can look around and see the game icons for other games all around. (May or may not eventually allow players to teleport to these games from mine via the game icons, haven’t decided yet.)

The script I have here works as intended, though with the occasional problem of icons not loading but I can work around that. The problem is that it takes forever to find games that match the criteria for what will work. I believe it took roughly an hour to find around 84 games that would work, so I would have to let the script run in studio for a little over 14 hours. Theoretically I could have multiple versions of this script running to speed it up, however if I recall correctly ContentProvider has something like a maximum of 500 requests per minute, though I don’t know if that’s per script or server or what, and this script runs right around 300-350 requests per minute I believe.

What I would like to know is if there’s a way to improve this script or go about another method of achieving my goal notably faster or if this is about the best I can hope for with maybe a couple tweaks?

cp = game:GetService("ContentProvider")
rs = game:GetService("RunService")

--print("Script Is Now Running")

buttons = {}
usedIds = {}

local gameTilesRows = game.Workspace.GameTiles:GetChildren()
for i = 1,#gameTilesRows do
	if gameTilesRows[i].Name == "Row" then
		local gameTiles = gameTilesRows[i]:GetChildren()
		for a = 1,#gameTiles do
			if gameTiles[a].Name == "GameButton" then
				if gameTiles[a].GameName.sgui.txtlbl.Text == "Game Tittle Here" then
					table.insert(buttons,gameTiles[a])
				end
			end
		end
	end
end

--print("Table Is Filled")

local currentTile = 1
local Details
local IconID
IsPlace = false
running = false
restart = false
local nr = Random.new()
local search
usedTime = tick()

function found(imageFound)
	local name = Details.Name
	if imageFound == true then
		IconID = Details.IconImageAssetId
		buttons[currentTile].GameIcon.sgui.igui1.Image = "rbxassetid://"..IconID
		buttons[currentTile].GameName.sgui.txtlbl.Text = name
	else
		buttons[currentTile].GameIcon.sgui.igui1.Image = "rbxassetid://"..5777081522
		buttons[currentTile].GameName.sgui.txtlbl.Text = name
	end
	return
end

local function look()
	print("Searching")
	local PLACEID = nr:NextInteger(40000,15000000000)
	if not table.find(usedIds,PLACEID) then
		table.insert(usedIds,PLACEID)
		--print(PLACEID)
		local Product = game:GetService("MarketplaceService")
		Details = Product:GetProductInfo(PLACEID)
		if Details then
			--[[print("Details")]]
			if Details.Creator then
				--[[print("IsCreator")]]
				if Details.AssetTypeId == 9 then
					--[[print("IsGame")]]
					if Details.IconImageAssetId ~=0 then
						--print("HasImage")
						--[[print(Details.Updated) ]]
						--[[print(Details.IconImageAssetId .. " Is The Icon")]]
						--print(PLACEID)
						IsPlace = true
						--[[print("Ok")]]
						local imageStatus = cp:GetAssetFetchStatus("rbxassetid://" .. Details.IconImageAssetId)
						if imageStatus ~= Enum.AssetFetchStatus.Failure then
							found(true)
							
						else
							--print("oop")
							found(false)
						end
						print("count is at " .. currentTile)
						if currentTile < #buttons then
							currentTile = currentTile + 1
						else
							if search ~= nil then
								search:Disconnect()
								search = nil

							end
						end
					end
				end
			end
		end
	end
	usedTime = tick()
	running = false
	restart = false
end

--print("Begin Searching")

search = rs.Stepped:Connect(function()
	if running == false then
		running= true
		pcall(look)
		--[[print("hi")]]
	end
	if tick() - usedTime > 5 then --[[AssumeError]]
		if restart == false then
			restart = true
			print("Oops")
			pcall(look)
		end
	end
end)

I should probably mention that i have considered using the immersive ads service as it would almost certainly load much faster. However it ultimately would not work.

First only users who are 13 or older can see them which would mean anyone who is under 13 would just see over a 1000 blank parts with the Roblox logo on them.

Second, from what i know anyway, there seems to be a bit of an issue where the ads don’t always load and just leave the base image of the Roblox logo.

Third, I’m uncertain if theres even a thousand immersive ads currently running.

Forth, the immersive ads require a specific scaling ratio for them to load. Even if i found a way to scale or fit them to look more like game icons, other than looking awkwardly squished or cropped, I don’t want to risk getting in trouble for bypassing a Roblox stated requirement. Which brings me to my last point.

Fith, given my current understanding of how they work, devs who put them in their games can get robux just from people looking at them. I’d rather not risk getting in trouble for making people look at hundreds of immersive ads at once and be accused of illegal farming robux by doing so or something of the like.

Have you considered using an External Server and make calls from the Roblox Game API?

You can parallelly make some get calls and compile the results in a single JSON string in your external source. Further, you can emit that to your game via another get call.

Though, I don’t know if 1000 API calls are allowed even from external sources. I haven’t attempted to do anything as such before.

To be honest, I’m not sure I’d even know where to begin with that. (Despite doing scripting stuff on Roblox for over a decade at this point, my skill with it are probably about mid. Never really been my forte)

I just got done testing separate studio instances running test servers, so as to imitate numerous servers and not run into the 500 requests a minute per server limitation that ContentProvider has. It worked for about 30 seconds or so, before each script running in the individual test servers simultaneously began experiencing the --[[AssumeError]] timer portion of my script then basically coming to a halt as either the ‘running’ or ‘restart’ boolen wasn’t being switched back to false as the very next call would get stuck as well (if that makes since).

Would you be able to point me to a good starting place as to how I may be able to accomplish what you’re suggesting? As for the potentially not being able to do 1000 API calls from an external sourse, it shouldn’t be too much of an issue as if nothing else I can do it in batches just so long as it’ll be notably faster than what I got right now.

I hope you can realise you can customize the image that the person sees if they do not see an ad, so you could make it that players that can see the ads, see the ads, and players that cannot see the ads will see your system.

Thank you, I am aware of this.
However as I listed above, there are a few other problems that would occur should I try to use immersive ads for what I’m attempting to do.
One major problem is that immersive ads cannot be any larger than 32 by 18 studs, which would not work for how large of a scale I am working on as the parts they would need to be displayed on are a little over 1400 by 1400 studs.

1 Like