Solved - MessagingService not sending to other servers

Solved, It was my own stupidity. Can’t filter a message from someone not in game. Needs to be before

  1. What do you want to achieve?
    Trying to send a small string to other servers via MessagingService
  2. What is the issue?

    Only the server that sent it gets the message sent.
  3. What solutions have you tried so far?
    I’ve looked around DevForums to see if anyone else has the same problem I do, I haven’t. I’ve tried adding prints both server-side and local which only go off on the originating server, so that means the other servers didn’t pick up on it.

Server:

local function handlePublish(plr, method, info)
	local decodedData = {
		method = method,
		info = info,
		id = plr.UserId
	}
	local encodedData = httpService:JSONEncode(decodedData)
    messagingService:PublishAsync("Info", encodedData)	
end

local function handleSubscribe(encodedData)
	local decodedData = httpService:JSONDecode(encodedData.Data)
	local method = decodedData.method
	local info = decodedData.info
	local id = decodedData.id
	local filterResult = TextService:FilterStringAsync(info, id, Enum.TextFilterContext.PublicChat)
	for i,v in pairs(game:GetService("Players"):GetChildren()) do
		bind:InvokeClient(v, method, filterResult:GetChatForUserAsync(v.UserId))
	end
end

bind.OnServerInvoke = handlePublish
messagingService:SubscribeAsync("Info", handleSubscribe)

Client:

local function handleSubscribe(method, info)
	print(method .. ":" .. "info")
	if method == "ga" then
		StarterGui:SetCore("ChatMakeSystemMessage", {
			Text = ("[Global Announcement] %s"):format(info);
			Color = Color3.fromRGB(116, 185, 255);
		})
	elseif method == "gw" then
		StarterGui:SetCore("ChatMakeSystemMessage", {
			Text = ("[Global Warning] %s"):format(info);
			Color = Color3.fromRGB(255, 118, 117);
		})
	else
		StarterGui:SetCore("ChatMakeSystemMessage", {
			Text = ("[Server] %s"):format(info);
			Color = Color3.fromRGB(130, 204, 221);
		})		
	end
end

bind.OnClientInvoke = handleSubscribe

“Delivery is best effort and not guaranteed. Make sure to architect your game so delivery failures are not critical.” Due to it saying this on the wiki I’ve tried sending multiple. All tests have definitely been under the 80char limit. I’m quite unsure why it is not sending to other servers (within same game/universe).

2 Likes

Would you mind either changing the title or marking the topic as solved so that it doesn’t seem like there is still a problem?

2 Likes

I don’t know how to mark as solved, edited the title

At the bottom of a reply, you can see the gray outline of a check box. Click it to mark that reply as the solution. As a side note, you should read the rules before posting and make sure you understand discourse (Roblox devFourm is built on it)

For example, instead of editing your topic you could reply with the solution, then mark that.

Solved, It was my own stupidity. Can’t filter a message from someone not in game. Needs to be before

1 Like