Hello, basically, I want to make something like in PLS Donate, where people can set up stands and have people dentate to them, I have the code to search the players Inventory for shirts:
local http = game:GetService("HttpService")
local baseUrl = "https://catalog.roproxy.com/v1/search/items/details?Category=3&Subcategory=13&Limit=30&CreatorName=%s&cursor=%s"
local function getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
tshirts = tshirts or {}
cursor = cursor or ""
local requestUrl = baseUrl:format(username, cursor)
local success, result = pcall(function()
return http:GetAsync(requestUrl)
end)
if success then
if result then
local success2, result2 = pcall(function()
return http:JSONDecode(result)
end)
if success2 then
if result2 then
for _, tshirt in ipairs(result2.data) do
table.insert(tshirts, tshirt.id)
end
cursor = result2.nextPageCursor
if cursor then
return getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
else
return tshirts
end
end
else
warn(result)
end
end
else
warn(result)
end
end
local username = "Roblox"
local userTShirts = getUserGeneratedTShirtsRecursive(username)
print(#userTShirts) --3
print(table.concat(userTShirts, " ")) --1031862 1036727 1031864
How would I take this data and put all of the product ids into a different Gui. (One Gui for each product) Also how would I each product Id into a different number value? Sorry If this didn’t make sense when you read it
Thanks, Mason
You can create a button with a script and an intvalue, and loop thru the usertshirts, creating a clone of the button, putting the id into the intvalue, and in the script u can make it so when you press the button it takes the id from the intvalue.
The code i used: local tableTS = table.insert(userTShirts, " ") for i, v in pairs(tableTS) do print(tableTS) end
It says: ServerScriptService.GameSystems.DonateGui:46: invalid argument #1 to ‘pairs’ (table expected, got nil)
You could just use the usertshirts table in the loop, also first argument of table.insert is the table in which you want to insert the value, and second argument is the value itself. Also when printing the values in the table print the v, since i is the index of the value(position in the table) while v is the value in that index.
game.Players.PlayerAdded:Connect(function(plr)
local baseUrl = "https://catalog.roproxy.com/v1/search/items/details?Category=3&Subcategory=13&Limit=30&CreatorName=%s&cursor=%s"
local function getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
tshirts = tshirts or {}
cursor = cursor or ""
local requestUrl = baseUrl:format(username, cursor)
local success, result = pcall(function()
return http:GetAsync(requestUrl)
end)
if success then
if result then
local success2, result2 = pcall(function()
return http:JSONDecode(result)
end)
if success2 then
if result2 then
for _, tshirt in ipairs(result2.data) do
table.insert(tshirts, tshirt.id)
end
cursor = result2.nextPageCursor
if cursor then
return getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
else
return tshirts
end
end
else
warn(result)
end
end
else
warn(result)
end
end
local username = plr.Name
local userTShirts = getUserGeneratedTShirtsRecursive(username)
print(#userTShirts) --3
print(table.concat(userTShirts, " "))
for i, v in pairs(userTShirts) do
local Template = script.Template:Clone()
Template.Parent = game.Workspace.Map.Booths:WaitForChild(plr.UserId):WaitForChild("DonateSign"):WaitForChild("SurfaceGui"):WaitForChild("Frame")
local MarketplaceService = game:GetService("MarketplaceService")
Template.Id.Value = table.concat(userTShirts, " ")
end
end)
I got it to make the Gui, but when I try to put the product Id's into the values, it keeps the value at zero. Is there a way to fix this?