MemoryStore ALWAYS returns nil

Hey everyone, i just started on my Matchmaking script, however I’ve faced an issue which I couldn’t solve for hours for some reason? Every time I do :AddAsync() to a MS queue, the id returns.. nil?


Please take a look at my code snippet :


local MemoryStoreService = game:GetService("MemoryStoreService")

    local queueName = string.format("%s_%d", QUEUE_PREFIX, wagerAmount)
	local matchQueue = MemoryStoreService:GetQueue(queueName)
	local items = matchQueue:ReadAsync(100, true, 1)
	print(`[MM_DEBUG] Using queue: '{queueName}'`)

	local dataToQueue: QueueItemData = {
		UserId = player.UserId,
		Wager = wagerAmount,
		QueueTime = os.time(),
	}

	-- Add to queue with retry logic (NO PRIORITY ARGUMENT)
	local itemId = nil
	local attempts = 0
	local MAX_ATTEMPTS = 3

	repeat
		attempts += 1
		local success, result = pcall(function()
			return matchQueue:AddAsync(dataToQueue, 600)
		end)
		print("AddAsync test:", success, result)

		if success then
			itemId = result
			break
		else
			warn(`[MM_DEBUG] AddAsync attempt {attempts} failed for {player.Name}. Error: {tostring(result)}`)
			task.wait(0.5)
		end
	until itemId or attempts >= MAX_ATTEMPTS

	if not itemId then
		warn(`[MM_DEBUG] FAILED to add {player.Name} to queue '{queueName}' after {MAX_ATTEMPTS} attempts.`)
    end

This somehow always prints the MM_DEBUG failed to add to queue message? Any help is appreciated :slight_smile:


edit : also, I’ve found this on the game analytics, although the game is currently private :

This didn’t happen before when it was still rejecting my :AddAsync call so i doubt it’s the real reason behind it!


It only returns nil on success

1 Like

Any idea why it might fail? Because it always does for some reason but the table IS valid.


The thing is, it doesn’t even succeed.

Not really, might be a Roblox issue I guess
What does AddAsync test say?

oh wait… i think i got it alright, thanks for the clarification again

I don’t know about the success, but ItemId will always be nil, as AddAsync doesn’t return anything

one last question, how should i set an item id? Perhaps with HttpService?

Personally to generate a Unique ID, I do this:
(16 chars only bc it’s for datastore

local function GenerateGUID(): string
	return HttpService:GenerateGUID(false):gsub("-", ""):sub(1, 16)
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.