Im making a party system for my game using the MemoryStoreService and I decided to use StoredMaps. I was using the documented example to get all of the items in a map (adapted slightly to meet my needs). It works great except when there are no items in the StoredMap when this occurs it errors. My code is below and the error it produces is also below. Is this a bug with GetRangeAsync or just my code?
function Lobby:PartiesReadAll()
local function getItems(lowerBound)
local worked, items = pcall(function()
return self.Parties:GetRangeAsync(Enum.SortDirection.Ascending, 200, lowerBound)
end)
if not worked then
error(worked)
--error("Failed to get all parties")
return getItems()
end
return items
end
local allItems = {}
local lowerBound = nil
while true do
local nextItems = getItems(lowerBound)
for i, v in pairs(nextItems) do
table.insert(allItems, v)
end
if #nextItems < 200 then
return allItems
else
lowerBound = nextItems[#nextItems].key
end
end
end