MemoryStoreQueue unsynchronized and not working properly

I’ve tried everything

With GetQueue the invisibility timeout needs to be 0 so I have to keep that at 0 but then it messes up everything

AddAsync the timeout needs to be considerably high, yet, if I make it high I cannot remove them

ReadAsync works fine

RemoveAsync doesn’t remove unprocessed values and I don’t know how to process stuck values

I need help synchronizing the script so that MemoryStore actually processes the values without giving me an error and then keeping values stuck in the queue.

Here is my code

local Players = game:GetService("Players")
local MSS = game:GetService("MemoryStoreService")
local MS = game:GetService("MessagingService")
local RS = game:GetService("ReplicatedStorage")
local TS = game:GetService("TeleportService")
--^ Services

local MMNS = MSS:GetQueue("MatchmakingNoSkillBased-"..game.GameId, 0) -- 30 seconds
--^ Service Variables

local remotes = RS:WaitForChild("Remotes")
local addPlayerFunction = remotes:WaitForChild("AddPlayer")
local removePlayerFunction = remotes:WaitForChild("RemovePlayer")
--^ Variables in Game

local currentServer = game.PrivateServerId
local currentAmount = 0
local plrTable = {}
--^ tables and counters

--change these
local playersNeeded = 1
local playersWanted = 4
--change these

local db = false
--^ debounces


function Main()
	local success, err = pcall(function()
		plrTable = MMNS:ReadAsync(100, false, 1)
	end)
	print(success, err)
	print("Above is Main MM Function")
	print(plrTable)
	if plrTable ~= nil then
		for i, player in ipairs(plrTable) do
			currentAmount += 1
		end
		
		if currentAmount >= playersNeeded then
			currentAmount = 0
			local playersSelected = {}
			
			local Succ, Err = pcall(function()
				playersSelected = MMNS:ReadAsync(playersWanted, false, 1)
				MMNS:RemoveAsync(playersSelected)
			end)
			
			print(Succ, Err)
			
			print("Game Found")
			if game.PrivateServerId then -- IMPORTANT DO ~= ""
				--local gameCode = TS:ReserveServer(7739088033)
				for i, plyr in ipairs(playersSelected) do
					print(plyr.." Teleporting")
					local playeR = Players:FindFirstChild(plyr) -- adds to table in then TeleportToPrivateServer handles it
					
				end
			else
				print("In studio")
			end
		else
			currentAmount = 0
			print("not enough")
		end
	else
		print("error in adding player")
	end
end

function Add(plr)
	local success, err = pcall(function()
		MMNS:AddAsync(plr.Name, 100, 1)
	end)

	if success then
		print("Player Added to Queue: "..plr.Name)
		Main()	
	else
		print(err)
	end
end

function Remove(plr)
	local success, err = pcall(function()
		MMNS:RemoveAsync(plr)
	end)
	
	print(success, err)
end

function RemoveAll()
	local success, err = pcall(function()
		local read = MMNS:ReadAsync(100, false, 1)
		MMNS:RemoveAsync(read)
	end)

	print(success, err)
end

game.Players.PlayerAdded:Connect(function(plr)
	Add(plr)
end)

game:BindToClose(function()
	RemoveAll()
end)
1 Like

Did you ever end up fixing this??
I’ve noticed the exact same thing.
Opened up 2 servers, one servers had a couple items in the queue and the other server was just completely oblivious to those items.