I have a function that is supposed to get all of a users t-shirts and put the ID’s in a table, but no matter the player it always returns the same three t shirts. Any ideas why this is?
local function getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
tshirts = {}
cursor = ""
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)
return getUserGeneratedTShirtsRecursive(winnerName)
end
end
local userTShirts = getUserGeneratedTShirtsRecursive(winnerName)
local Http = game:GetService("HttpService")
local function FormatUserGeneratedTShirtsEndpoint(UserId, Cursor)
Cursor = Cursor or ""
return "https://www.catalog.roproxy.com/v1/search/items/details?Category=Clothing&Subcategory=ClassicTShirts&Limit=30&CreatorTargetId="..UserId.."&Cursor="..Cursor
end
local function TableConcat(TableA, TableB)
local TableC = {}
for i, v in ipairs(TableA) do
table.insert(TableC, v)
end
for i, v in ipairs(TableB) do
table.insert(TableC, v)
end
return TableC
end
local function GetUserGeneratedTShirts(UserId, Limit, Cursor)
local TShirts = {}
local Endpoint = FormatUserGeneratedTShirtsEndpoint(UserId, Cursor)
local Success, Result = pcall(function()
return Http:GetAsync(Endpoint)
end)
if not Success then
warn("Unable to get t-shirts from API: "..Result)
return TShirts
end
local Success2, Result2 = pcall(function()
return Http:JSONDecode(Result)
end)
if not Success2 then
warn("Unable to decode response from t-shirts API: "..Result2)
return TShirts
end
for _, TShirt in ipairs(Result2.data) do
table.insert(TShirts, TShirt.id)
end
if #TShirts >= Limit then
return TShirts
else
Cursor = Result2.nextPageCursor
if Cursor then
local MoreTShirts = GetUserGeneratedTShirts(UserId, Limit, Cursor)
return TableConcat(TShirts, MoreTShirts)
else
return TShirts
end
end
end
Hi, I have just tested the script and I was just wondering what I pass into the function for the variable ‘cursor’. Before I only passed in the playerID but I think this script gives an error unless a value for cursor is passed through.
Sorry, another error ‘ServerScriptService.Arena1Script:205: attempt to compare nil <= number’
Sorry I keep sending these to you, I’m still new to scripting