(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)