Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to cache Roblox catalog gear?

Asked by 7 years ago

Hello, I'm trying to make a Roblox game that references gear from the catalog without adding every single gear into my game into storage.

Is there any way to accomplish this?

If so, can you give some sort of function or something?

Thank you!

0
Do you mean like listing multiple Gear to the UI? xenoslav 7 — 7y
0
I'm thinking of getting a random gear from the catalog, but I'm not trying to sound like I'm making a script request. SpazzMan502 133 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

I've wanted to do something similar before, the best approach I came up with was compiling a complete list of gear ids and putting them in a table so that i could spawn a random gear from that list. The list below is incomplete but just an example as to the setup. The script below would be used to give the player a random gear when they chat "r".

gears = {99797357, 99797381, 99797403, 99797327, 94794774, 99641902, 99610601, 99119158, 99119198, 97161241, 99254437, 99254358, 99119261, 99254241, 99119240, 83021197, 99254203, 99254164, 92142841, 87361662, 99130630, 99033296, 98411393, 98411436, 98970218, 98341183, 98253651, 98411325, 98253626, 98253592, 98346415, 13745494, 98253569, 98219158, 97932897, 97885552, 97885508, 97885572, 97885289, 97886188, 97756645, 97712291, 97311482, 97161262, 97161295, 96669943, 96669687}

function onMsg(msg, ply)
 if msg == "r" then
for i = 0,10 do
        local model = game:GetService("InsertService"):LoadAsset(gears[math.random(#gears)])
        for _,v in pairs(model:GetChildren()) do
                if v:IsA("Tool") or v:IsA("HopperBin") then
                    v.Parent = ply.Backpack
                end
            end
        end
    end
end

game.Players.PlayerAdded:connect(function(ply)
    ply.Chatted:connect(function(msg) onMsg(msg, ply) end)
end)

for _,ply in pairs(game.Players:GetPlayers()) do
    ply.Chatted:connect(function(msg) onMsg(msg, ply) end)
end
0
Thanks, I'll try to work that into my script. SpazzMan502 133 — 7y
0
How could I change this script so instead of it giving you gear when you chat "r", it'll just give them when you spawn? Cynical_Potatoe 5 — 4y
Ad

Answer this question