Hello, I’ve been working on a queue system using MemoryStoreService with the following code:
--[[
- @ Author: ZephyriaLysa
- @ Create Time: 2025-11-27 21:21:56
- @ Modified by: ZephyriaLysa
- @ Modified time: 2025-11-28 00:07:34
- @ Description: This is the main module for the queue system.
]]
--// Types
type queueData = { userId: number, gameType: string, timestamp: number }
--// Services
local MemoryStoreService = game:GetService("MemoryStoreService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
--// Modules
local Keys = require(ReplicatedStorage.Shared.Config.Keys)
--// Stores
local queueStore = MemoryStoreService:GetQueue("PlayerQueue")
--// Settings
local DEFAULT_GAME_TYPE = "FFA"
local EXPIRATION = 5
--// Module
local Queue = {}
--// Functions
-- Adds the player provided to the queue.
function Queue.AddToQueue(player: Player, gameType: string): boolean
if typeof(player) ~= "Instance"
or not player:IsA("Player")
then
warn("⚠️ | No player provided to add to the queue.")
return false
end
if player:GetAttribute("InQueue") then
warn("⚠️ | @" .. player.Name .. " is already in queue.")
return false
end
gameType = if typeof(gameType) == "string" then gameType else "FFA"
local data: queueData = {
userId = player.UserId,
gameType = gameType,
timestamp = os.time(),
}
local success, err = pcall(function()
queueStore:AddAsync(data, EXPIRATION)
end)
if success then
print("✅ | Successfully added @" .. player.Name .. " to the queue, expiration: '" .. tostring(EXPIRATION) .. "'.")
player:SetAttribute("InQueue", true)
return true
end
print("❌ | Failed to add @" .. player.Name .. " to the queue: " .. err)
return false
end
-- Checks if the player provided is in the queue.
function Queue.IsInQueue(player: Player?): boolean
if typeof(player) ~= "Instance"
or not player:IsA("Player")
then
warn("⚠️ | No player provided, can not check if they're in queue")
return false
end
local success, data = pcall(function()
return queueStore:ReadAsync(10)
end)
if not success then
warn("⚠️ | Could not retrieve queue data: " .. data)
return false
end
local playerFound = false
for key, value: queueData in pairs(data) do
if value.userId == player.UserId then
playerFound = true
break
end
end
print("✅ | Checked if @" .. player.Name .. " is in the queue, returned '" .. tostring(playerFound) .. "'.")
return playerFound
end
--// Module Exporting
return Queue
However, when I execute the function IsInQueue(player), it returns the following error after waiting for a long amount of time:
MemoryStoreService: InternalError: Internal Error. API: Queue.Read, Data Structure: UnknownMemoryStoreQueue.