Hello! I want to make my own catalog gui with roblox gears. And I have heard you can insert all Roblox gears into a game using roblox api system. But I don’t understand how this works, would appreciate if anyone could explain and possibly give a step by step explaination how I can get it setup for my game.
you can use InsertService:LoadAsset()
and insert the desired gear ID between the parentheses to insert the desired gear into your game
if you want the gear to go directly to a player’s backpack, you must get the Tool
child of the model returned by LoadAsset()
(FindFirstChildOfClass("Tool")
) and parent it to the player’s backpack (Player.Backpack
)
if you want to stay in the game before giving it to a player or just want to store it in the game, you must parent the model returned by LoadAsset()
inside Workspace
, ServerStorage
, or any container object so that it won’t get ‘deleted’ (unless it’s still defined as a variable in a script)
The example code below gives a random player the sword gear.
local Players = game:GetService("Players") -- the Players object/service
local InsertService = game:GetService("InsertService") -- the InsertService object/service
local SwordGearID = 125013769 -- gear id/asset id of the sword gear
local GearModel = InsertService:LoadAsset(SwordGearID) -- gets a model containing the sword gear
local Sword = GearModel:FindFirstChildOfClass("Tool") -- gets the child in the model with the class "Tool" (which means it is a tool/gear); i used this instead of FindFirstChild("LinkedSword") in case Roblox changed the named of the gear (which is highly unlikely)
local allPlayers = Players:GetPlayers() -- gets an array/table containing all players in the game
local randomNumber = math.random(1, #allPlayers) -- gets a random integer between 1 and the number of all players in the game
local randomPlayer = allPlayers[randomNumber] -- gets the nth player in the game
Sword.Parent = randomPlayer.Backpack -- parents the sword gear inside the player's backpack
p.s. i think this post should be in either #help-and-feedback:scripting-support or #help-and-feedback:platform-usage-support so move the post there
Is there any way like I said to insert all gears on a certain category? By using the External Catalog Queries. Because I want to insert all gears from TownAndCity category.
Like what you said, you can use the web api https://catalog.roblox.com/v1/search/items/details from External Catalog Queries i legit didn’t know this existed until you mentioned that lol
Sadly, you can only get a maximum of 30 gears, as stated in External Catalog Queries. The link to get the list of gears (in JSON format) is https://catalog.roblox.com/v1/search/items/details?Category=11&Subcategory=5&Genre=1&Limit=30
but to get a specific genre, you simply put the Genre parameter (&Genre=
) at the end of the link and put a number next to it that corresponds to the desired genre (see list below).
Since you want the Town and City genre, we put &Genre=1
next to the link. So our link now will be https://catalog.roblox.com/v1/search/items/details?Category=11&Subcategory=5&Genre=1&Limit=30&Genre=1
.
If you try this, you will get an error. It’s because you can’t access the Roblox API directly in Studio. So we need to use a proxy. You can use any proxy out there, but I’ll be using roproxy.com
so the link will be https://catalog.roproxy.com/v1/search/items/details?Category=11&Subcategory=5&Genre=1&Limit=30&Genre=1
.
local HttpService = game:GetService("HttpService")
local api = "https://catalog.roblox.com/v1/search/items/details?Category=11&Subcategory=5&Genre=1&Limit=30&Genre=1"
local info = HttpService:GetAsync(api)
There’s another problem. The output is in JSON format, but we need to convert it into a table so we can use it. It’s an easy fix. You just use HttpService:JSONDecode()
.
local HttpService = game:GetService("HttpService")
local api = "https://catalog.roblox.com/v1/search/items/details?Category=11&Subcategory=5&Genre=1&Limit=30&Genre=1"
local info = HttpService:GetAsync(api)
local decodedInfo = HttpService:JSONDecode(info)
So now we got a table that contains the gear IDs. To insert all the load IDs, we will loop through decodedInfo.data
and for every value, we get the id
property of that value and insert that gear using InsertService:LoadAsset()
(you will know how to use that from my first reply).
local InsertService = game:GetService("InsertService")
local HttpService = game:GetService("HttpService")
local api = "https://catalog.roblox.com/v1/search/items/details?Category=11&Subcategory=5&Genre=1&Limit=30&Genre=1"
local info = HttpService:GetAsync(api)
local decodedInfo = HttpService:JSONDecode(info)
for _, value in decodedInfo.data do
local GearModel = InsertService:LoadAsset(value.id)
local Gear = GearModel:FindFirstChildOfClass("Tool")
end
And let’s give all of it it to a random player
local Players = game:GetService("Players")
local InsertService = game:GetService("InsertService")
local HttpService = game:GetService("HttpService")
local api = "https://catalog.roblox.com/v1/search/items/details?Category=11&Subcategory=5&Genre=1&Limit=30&Genre=1"
local info = HttpService:GetAsync(api)
local decodedInfo = HttpService:JSONDecode(info)
local allPlayers = Players:GetPlayers()
local randomNumber = math.random(1, #allPlayers)
local randomPlayer = allPlayers[randomNumber]
for _, value in decodedInfo.data do
local GearModel = InsertService:LoadAsset(value.id)
local Gear = GearModel:FindFirstChildOfClass("Tool")
Gear.Parent = randomPlayer.Backpack
end
And there you have it! A code that gives a random player 30 gears in the genre “Town and City”. You can modify it whatever you want.
Thank you so much! That is so much effort, very kind of you. I’m also going to try to learn this stuff on my own now.
Whenever I modify the local api genre it’s not changing and not giving me any gears, I changed it to SciFi (3).
This is how it looks:
local HttpService = game:GetService(“HttpService”)
local InsertService = game:GetService(“InsertService”)
local Players = game:GetService(“Players”)
local api = “https://catalog.roproxy.com/v1/search/items/details?Category=11&Subcategory=5&Genre=3&Limit=30”
local info = HttpService:GetAsync(api)
local decodedInfo = HttpService:JSONDecode(info)
local allPlayers = Players:GetPlayers()
local randomNumber = math.random(1, #allPlayers)
local randomPlayer = allPlayers[randomNumber]
for _, value in decodedInfo.data do
local GearModel = InsertService:LoadAsset(value.id)
local Gear = GearModel:FindFirstChildOfClass(“Tool”)
if Gear then
Gear.Parent = randomPlayer.Backpack
end
end
sorry for the late reply
can you show the output? im not sure if the error is the api itself or it has something to do with the player
Hey, I’ve solved it. However, I could use your help with something simple if you’re available. I’ve gathered a bunch of gear IDs, and I want to insert them with a simple script so that when a player joins the game, they’ll be in the starterpack. How can I make this happen?
The gear IDs are:
{1981813154, 834681176, 1320966419, 2274759555, 2646396550, 2713323785, 80597060, 120307951, 69499437, 139577901, 233520257, 93136802, 159229806, 73829193, 99119240, 80661504, 108158379, 2544549379, 2646379006, 2605966484, 2530753967, 2605965785, 2569028708, 2588272910, 2548993638, 2548989639, 2544748094, 1245307956, 2535472650, 2544539559, 2103274863, 135518721, 168142114, 2535102249, 2506365260, 1513260464, 74904413, 880499904, 87361995, 2470977704, 2470915740, 155661985, 147143821, 64647651, 159199263, 56561579, 60357982, 82707568, 2413755690, 2409287383, 2409286506, 2290921705, 2385189785, 2350122208, 2261478942, 62827106, 2222652960, 2291005315, 365674685, 2163549594, 1789547756, 64220933, 2016189421, 945527020, 583030187, 1903666770, 1665544157, 1868405032, 1856115349, 1829078563, 548019247, 1748600996, 1760406591, 891924036, 845527166, 675312894, 658805662, 583007360, 583026228, 535104095, 467895641, 431047232, 431044405, 431042935, 405991634, 375832969, 375829909, 346687946, 302063713, 302030998, 278009025, 241542047, 232520546, 223800426, 193743245, 188854357, 188644771, 184757813, 184757948, 180298135, 172289170, 1694661592, 1694623317, 1560398824, 1466341532, 1466353882, 144510568, 140490812, 139581823, 139574344, 1377984056, 136213778, 134111541, 130167063, 128210518, 124908320, 122330194, 1213388821, 121121915, 1076467071, 1076457286, 1016496274, 1241156683, 49929767, 88885481, 158069180, 55917409, 435116927, 1602503043, 1678314358, 223785065, 55917420, 21294489, 168141496, 59190534, 48159731, 181356054, 483308034, 168140949, 172298750, 1645056094, 746686384, 608818868, 173755801, 156467990, 120749528, 95951330, 73232803, 1609498185, 28277195, 12187348, 1587165780, 86494893, 71037101, 168141301, 176087505, 45177979, 1560608167, 10468797, 1560600467, 243791329, 12145515, 21754543, 928794651, 49929724, 287426148, 85145626, 22787168, 147143863, 1427402900, 1536052210, 11956382, 50938746, 1513262045, 51757162, 1492226137, 1340206957, 1360077860, 361950297, 1402322831, 1380788230, 1363010936, 743687369, 501940219, 501941714, 880453518, 880448457, 501753915, 501939119, 501755654, 1145081326, 743692189, 743691009, 501942750, 1363011928, 1363019628, 1363020083, 221181437, 1241586595, 1208300505, 66823689, 250407413, 1215506016, 1208300973, 1145358304, 1076255449, 1103011681, 1117745433, 1117743696, 315617026, 1088051790, 1088051376, 427947884, 1060280135, 1046323916, 1046322934, 999866560, 346686597, 1033136271, 972189904, 25740034, 98411325, 77443704, 85150872, 90211299, 77443436, 85150978, 75906973, 66416579, 68233678, 61459718, 64647666, 56561593, 62350867, 50938773, 50454041, 49491808, 51760061, 54694334, 49929746, 52938493, 435116454, 44561343, 49052716, 44115185, 47871597, 45513203, 43708943, 489196923, 37816777, 341110180, 42847923, 24440014, 23727705, 22788134, 24713330, 26945832, 244081145, 28275809, 22158176, 23306097, 25545089, 24346755, 22152234, 22787189, 18409191, 21439778, 186958653, 20721924, 21445765, 18017365, 18482570, 21439893, 20577851, 21416138, 18776718, 21802000, 18481407, 146047188, 139578571, 108148416, 108153884, 124472052, 108148449, 128209615, 119917556, 928914739, 936703279, 903199054, 903197575, 846792499, 51346471, 34398653, 26777410, 13207169, 12775410, 12187431, 12187319, 10468915, 754871615, 754869699, 83704165, 68603324, 16895215, 73799348, 746687364, 16641274, 125013769, 81154592, 725802037, 709400407, 698862470, 431038614, 181550181, 629893424, 602146440, 95484098, 96501454, 93667422, 583157224, 566780253, 390969719, 335086410, 317593132, 302502491, 295461517, 286526788, 286526176, 268533320, 255800577, 243791145, 233519998, 191261930, 188853857, 187688069, 14719505, 14131602, 14131296, 11885154, 11453385, 11452821, 10910681, 10831489, 10758456, 10730984, 10510024, 10469910, 532254782, 517827255, 522587921, 503955938, 483308681, 489197999, 478707595, 68848741, 416846710, 409745306, 186959114, 413199938, 402304782, 398122525, 398122908, 94794774, 93136746, 76596299, 72069888, 62350856, 170897263, 383609201, 264990158, 356213216, 334620353, 335085355, 243778818, 317593302, 306971659, 306971294, 302280931, 295460702, 123234673, 124128001, 287424278, 280662903, 280662667, 268586231, 257829534, 264991177, 261826521, 261826406, 161075864, 95951291, 254608905, 243790334, 244082303, 160198658, 241511828, 241512134, 241017426, 241017568, 64372667, 54130559, 46360920, 105351503, 101191388, 108149175, 226205948, 109583771, 225921137, 223439643, 14876573, 11999235, 218631128, 63721724, 81155006, 168142394, 94794833, 93725362, 257811449, 212500257, 50938765, 73232786, 101106419, 48395736, 96669943, 53623322, 92142829, 61963621, 79736586, 206136361, 206136532, 83704179, 72069827, 178076749, 181469279, 183665594, 202039834, 204095724, 204095670, 186867671, 189756588, 121946387, 184758713, 183665514, 183797762, 183826384, 183355969, 82357079, 182273799, 92628079, 89487903, 109364052, 46360870, 48159648, 74385386, 174752186, 170903610, 170902990, 168140813, 53623350, 36568418, 36568603, 38326803, 83704190, 142498104, 68539623, 160198363, 160189476, 160189871, 160189629, 159199218, 158069110, 158069071, 157205837, 156467855, 156467926, 153939072, 148812192, 149612243, 147937443, 147143848, 147143881, 68478587, 139578136, 139578061, 58880579, 94794847, 134109039, 78665196, 127506364, 127506324, 126719120, 126719148, 125013849, 105351572, 47262951, 46846024, 64870000, 117498849, 116693735, 85879456, 114020557, 112591894, 109583846, 108875151, 108158439, 108149201, 105430216, 105351545, 107458531, 106701702, 106064277, 106064469, 105289761, 105189286, 105179506, 103359953, 97161222, 100469994, 99797381, 99199463, 87361662, 96669687, 96669697, 96669682, 93536867, 93536785, 93136674, 93136666, 92627988, 69947367, 71422327, 71422340, 77443461, 77443491, 32858699, 66823631, 67998086, 86692539, 91517984, 83704169, 89203895, 86494914, 60791062, 85879447, 84418938, 83704154, 81847570, 78665204, 75906942, 75550928, 73829214, 71422361, 71597048, 71037076, 69947379, 55028088, 54694311, 65469908, 67319425, 65469882, 65969704, 65079090, 64870021, 62803165, 64735604, 63253718, 62809243, 64372659, 62350883, 62350846, 60888308, 60888284, 60357959, 59175777, 48159815, 55194474, 54694329, 54694324, 54130537, 54130543, 53623248, 53130850, 51757126, 36431591, 51302649, 51346336, 32858586, 26421972, 46132907, 44561450, 40493542, 37821996, 30847746, 27171403, 17680660, 16435368, 16433862, 10831509, 15176169, 15470359, 15970544, 13206984}
that’s… alot….
just loop through the table and load every value
also this time, we will give it to every player who joins the game
local function playerJoins(player: Player)
for _, gearId in gearIds do -- gearIds is the table you made
local GearModel = InsertService:LoadAsset(gearId)
local Gear = GearModel:FindFirstChildOfClass("Tool")
Gear.Parent = player.StarterGear -- i used StarterGear instead of Backpack so that whenever the player respawns, they will still have it in their inventory
end
end
-- in case there are players already in the game before Player.PlayerAdded fires
for _, player in allPlayers do
task.spawn(playerJoins, player)
end
Players.PlayerAdded:Connect(playerJoins)
Problem resolved, thank you for all the help.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.