im making a lobby system for my game and im using MemoryStoreService to save/store the lobbies for other servers, but it doesnt add the keys to the SortedMap, there are no errors
Lobby creation code:
game.ReplicatedStorage.CreateLobby.OnServerEvent:Connect(function(plr,TeleData)
local s,f = pcall(function()
local ReservedServerCode = TeleportService:ReserveServer(game.PlaceId)
--local ReservedServerCode = "DEBUG_CODE"
if TeleData.PIN ~= "" then
TeleData.PINNeeded = true
end
local Data = {TeleData,ReservedServerCode}
local s,f = pcall(function()
for _,v in pairs(PlayerLobbys:GetRangeAsync(Enum.SortDirection.Ascending,200)) do
if v.key == LobbyName then
error("Lobby name already used!")
end
end
PlayerLobbys:SetAsync(TeleData.LobbyName,Data,172800)
print("Added Lobby to PlayerLobbys") -- Gets printed so it should have added it
end)
if f then warn(f) end
task.wait(1)
TeleportService:TeleportToPrivateServer(game.PlaceId, ReservedServerCode, {plr})
end)
if f then
print(f)
end
end)
and this is the code that checks for new lobbies
coroutine.resume(coroutine.create(function()
while task.wait(5) do
local s,data = pcall(function()
return PlayerLobbys:GetRangeAsync(Enum.SortDirection.Ascending,200)
end)
if typeof(data) == "string" then
warn(data)
elseif typeof(data) == "table" then
print("data.value")
print(data.value) -- prints nil
if tostring(data) ~= "{}" and data.key then
local keydata = nil
for _,v in pairs(data) do
local key = v.key
keydata = v.value
end
if keydata then
local CutData = {
LobbyName = keydata[1].LobbyName,
Players = keydata[1].Players,
PlayerAmount = keydata[1].PlayerAmount,
}
game.ReplicatedStorage.PlayerLobbys:FireAllClients(CutData)
end
end
end
end
end))
I dont think i have anything wrong as i dont get any errors
Note: This is my first time using MemoryStoreService