Sending messages to all of the servers using memory store service

So I have been trying to send messages across all of the currently available servers. To do this, I have done such that when player chats it sends the player’s message into a queue in memory service, that is supposed to be read in all of the currently active servers.

However, what ends up happening is that when a message is added to the queue, it is only read by one of the servers. For example, if I had 3 servers currently active, and one of the players in any of the servers chats, that message will only be read on 1 of the 3 servers.

Anyone know how to fix this?

My code:

local queue = game:GetService("MemoryStoreService"):GetQueue("Chat") -- queue

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg) -- detects when a player chats
		queue:AddAsync(msg,5) -- adds the player's msg to the queue, with 5 seconds to expire
	end)
end)

while true do -- loop that keeps checking if there is anything in the queue
	local success, data, id = pcall(function() -- reads
		return queue:ReadAsync(1)
	end)
	if not success then wait(0.1) print(data) continue end -- if there's nothing, wait
	workspace.MessageBrick.SurfaceGui.TextLabel.Text = data[1] -- displays the message on a Gui
end
1 Like

Yes thats how MemoryStoreQueue works

but you can use

https://developer.roblox.com/en-us/api-reference/class/MemoryStoreSortedMap

or

https://developer.roblox.com/en-us/api-reference/class/MessagingService

all servers will be able to get the data with MemoryStoreSortedMap or MessagingService

You should use MessagingService for this kind of stuff.

Messaging service is a better option than memorystoreservice