I fond myself having to transfer over 300 shirts and over 500 decals into my game(not while running it I just need those for my game)
This will take over 14 straight hours by copying from my web then pasting in studio manually so there must be another way. I heard of the InsertService and am wondering if I could write a small code and search the title of my decals to do the work for me.
If you can get all of the ids for the shirts and decals into a text file, then you can run a script to loop through all of them.
Given the id of a shirt or decal, you can insert the object at that id to get a Shirt or Decal object. I’m not sure if InsertService will do this, but I know that game:GetObjects will.
This would look something like:
local urls = [[
https://www.roblox.com/library/1772424855/Check-Locked
https://www.roblox.com/catalog/1668107243/Faded-Nike
https://www.roblox.com/catalog/1721442724/VS-PINK-Maroon-Off-Shoulder-Top-Sale
https://www.roblox.com/catalog/1768703248/GUCCI-SNAKE
]]
-- just one of my decals and top shirts from the catalog
for id in urls:gmatch("/(%d+)/") do
local assetUrl = "rbxassetid://"..id
print("Inserting "..assetUrl.." to ServerStorage")
spawn(function()
local success, err = pcall(function()
local objects = game:GetObjects(assetUrl)
for _, object in next, objects do
object.Parent = game.ServerStorage
end
end)
if not success then
warn("Failed to insert "..assetUrl.." because "..tostring(err))
end
end)
end
--[[
"/(%d+)/" is a pattern
/ matches a "/"
%d matches any number
%d+ matches 1 or more numbers
(%d+) matches 1 or more numbers and returns it
/ matches a "/"
In summary, "/(%d+)/" matches a slash, numbers, then another slash, and it returns the numbers.
Gmatch will loop through all matches in a string.
]]
You have to run this in the command bar, as a plugin, or using the “Run Script” tool in Studio in order to use GetObjects.
Assuming you copy the urls manually then it’s certainly easier to paste urls into a big list than it is to paste into properties of objects in Studio.
You don’t have to do it manually, though. You presumably already have a list somewhere. Maybe it’s in your bookmarks, or maybe it’s in your favorited items on the website, or maybe it’s in your inventory.
You can write a small bit of JavaScript and run it in your browser to output all of the urls for all of the pages, which you can then plug in to the above snippet to get into Studio.
Where or how do you have all of the links to these shirts and decals saved?
Actually I have a better idea. Sense I uploaded them all around the same time I could get the ids of the first Shirt and the if of the last Shirt and check all the shirts in between to see if they are mine then if so just import them into my game with the given name.
To give you an example, the following JavaScript will output a list of the urls of everything in the opened inventory page:
(function() {
let list = "";
let last = null;
function logAndAdvance() {
let assets = document.getElementById('assetsItems').getElementsByClassName('item-card-link');
if (assets[0] == last) {
console.log(list);
return;
}
last = assets[0];
for (object of assets) {
list += object.href + "\n";
}
document.getElementsByClassName('pager-next')[0].children[0].click();
setTimeout(logAndAdvance, 1000);
}
logAndAdvance();
})();
You can run this in the Console tab of your browser’s Developer Tools. Normally, you can access the Developer Tools using F12.
If it finishes too early, it’s likely because you have slow internet and it took more than 1 second to load the next inventory page. You can change 1000 to a higher number to wait more time between pages. 1000 is 1 second, 2000 is 2 seconds, etc.
Doing my way will make it soo I don’t need to assign them to there matching name. I could just use some code to do all the work. But I’ll do that if I my other idea fails.