I made an announcement system and want to make it appear in all servers. I tried using the messaging service but cant seem to make it work
Here is the server script, i would appreciate if someone could help me make it global (appear in all servers at once)
local event = game:GetService("ReplicatedStorage").events.globalmessage
event.OnServerEvent:Connect(function(player, type, ...)
if type == "sendmsg" then
local message = ...
local filter = game:GetService("Chat"):FilterStringForBroadcast(message, player)
event:FireAllClients("newmsg", filter)
end
end)
-- Services
local MessagingService = game:GetService("MessagingService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChatService = game:GetService("Chat")
-- Variables
local GlobalMessageEvent = ReplicatedStorage:WaitForChild("events"):WaitForChild("globalmessage")
-- Code
GlobalMessageEvent.OnServerEvent:Connect(function(Sender, Type, Message)
if Type == "sendmsg" then
local Filter = ChatService:FilterStringForBroadcast(message, player)
MessagingService:PublishAsync("Global Message", Filter)
end
end)
-- Publish global messages
MessagingService:SubscribeAsync("Global Message", function(NotificationMessage)
print(NotificationMessage.Data[1])
end)