How to make cross server announcements?

Hey! I was wondering how could I make game-wide announcements IN CHAT so basically how do I make a system where I can make a announcement to every server in a game through the chat. I know you use messaging service but I can’t find good tutorials on it.

What about this one?

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

1 Like

I have created an cross-server announcement system for you. You will have to download the RBXM file, because individually copying and pasting the scripts will take a long time.

Instructions

  1. Download this RBXM file:
    AnnounceSystem.rbxm (2.6 KB)

  2. Open your studio and right-click on ServerScriptService

  3. Find a button that says ‘Insert from File…’ and click it

  4. Navigate to the AnnounceSystem.rbxm (which you just downloaded) and insert it into ServerScriptService.

  5. You have completed the setup, but now I will demonstrate how to send cross-server announcements.

Demonstration

  1. Create a server-sided script and place it in ServerScriptService.
  2. Copy and paste either the help/tutorial code or the working code below into your script:
Help Code
local ServerScriptService = game:GetService("ServerScriptService")
local AnnounceSystem = ServerScriptService:WaitForChild("AnnounceSystem")

local CrossServer = require(AnnounceSystem:WaitForChild("CrossServer"))

--[[
Instructions on how to use the CrossServer module:

-- Announcing --

1. The line of code to announce is:
CrossServer:Announce("Test message")

]]
Working/Functioning Code
local ServerScriptService = game:GetService("ServerScriptService")
local AnnounceSystem = ServerScriptService:WaitForChild("AnnounceSystem")

local CrossServer = require(AnnounceSystem:WaitForChild("CrossServer"))

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
	CrossServer:Announce(Player.Name .. " has joined a server!")
end)
  1. If you do not like the font or text color, you can edit it inside of the LocalScript in this path: ServerScriptService.AnnounceSystem.Announcements.Client.AnnounceClient
    Help with setting font, color, etc

Conclusion
I have tested everything myself and it should be working fine. The downside of using MessagingService is that you can only input string/UTF+8 chars, not tables (including the message info [font, color, etc] for instance). To solve this, you could use RemoteEvents.

Disclaimer
I’m pretty sure that MessagingService only works in-game, so expect errors if you’re testing this in studio.

4 Likes

thanks! very nice and detailed!

Its giving an error that message is nil for somereason

Fix:

function Cross.Announce(message)
	if isServer then
		coroutine.wrap(function(message) -- Pass message as an argument
			local success, subscribeFunc = pcall(function()
				return MessagingService:SubscribeAsync(MessagingTopic, function(Message)
					AnnounceRemote:FireAllClients(Message.Data)
				end)
			end)

			if success then
				subscribeFunc:Disconnect()
			end
		end)(message) -- Pass message as an argument

		coroutine.wrap(function(message) -- Pass message as an argument
			MessagingService:PublishAsync(MessagingTopic, message)
		end)(message) -- Pass message as an argument
	end
end