im trying to make a table that has a bunch of items from the catalogue in it, but when i put it in pairs, it tells me, “Table expected, got string” and when i use string:separate it says “String expected, got table”
it just wont make up its mind!!
script
local event = game.ReplicatedStorage.Events.InsertModels
local marketplaceservice = game:GetService("MarketplaceService")
local insertservice = game:GetService("InsertService")
local assetservice = game:GetService("AssetService")
local Http = game:GetService("HttpService")
local AssetTypes = {
["Hat"] = 9,
["Shirt"] = 12,
["Pants"] = 14
}
local url = "https://catalog.roproxy.com/v2/search/items/details?Subcategory="..AssetTypes["Hat"].."&SortType=0&SortAggregation=5&Limit=30"
local pages = 25
local assets = {}
event.OnServerEvent:Connect(function(player,idx)
print("created")
for i = 1, pages do
local response = Http:GetAsync(url)..tostring(i)
local data = Http:JSONEncode(Http:GetAsync(url))
data = Http:JSONDecode(data)
print(data)
repeat wait(1)
print("hi")
if typeof(data) ~= table then
print("the type of data is "..typeof(data))
data = string:split(',')
end
until
typeof(data) == table
for _, asset in pairs(data) do
print("start")
local name = asset.Name
local id = asset.AssetId
assets[#assets + 1] = "{Id = " ..id .. ", Name = \"" .. name .. "\"}"
print(name)
end
print(i)
end
local source = "return { \n\t" .. table.concat(assets, ",\n\t") .. "\n}"
print(source)
end)