Global Announcement isn't working

I have a webserver connected to a Discord bot and when I do ?announce on the bot it sends a request to Roblox for Roblox to announce it on the servers. At first, I thought it worked, but when I started testing it with multiple servers, it only showed up for 1 server. This is my current code

while true do
	local request
	
	local suc, err = pcall(function()
		request = HttpsService:GetAsync(_G.baseReplUrl .. _G.getRequestEndpoint)
	end)
	
	if err then
		warn("There was an error while attempting to connect to the administration webserver: " .. err)
	end
	
	local newRequest
	
	local s, e = pcall(function()
		newRequest = HttpsService:JSONDecode(request)
	end)
	
	if s == true then
		adminSystem:Run(newRequest.type, newRequest)
	end
	
	wait(5)
end

The :Run() function that it’s calling

function module:Run(command, req)
	for _,v in pairs(script:GetChildren()) do
		if v.Name == command and v:IsA("ModuleScript") then
			return require(v):Run(req)
		end
	end
end

The :Run() function that this is calling

function module:Run(request)
	local players = game:GetService("Players"):GetPlayers()
	local TweenService = game:GetService("TweenService")
	
	local info = TweenInfo.new(
		3,
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)
	
	for _,v in pairs(players) do
		local clone = script.Parent.Components["Announcement GUI"]:Clone()
		
		local mainTween = TweenService:Create(clone.Main, info, {BackgroundTransparency = 0})
		local dividerTween = TweenService:Create(clone.Main.Divider, info, {BackgroundTransparency = 0})
		local closeTween = TweenService:Create(clone.Main.Close, info, {BackgroundTransparency = 0, TextTransparency = 0})
		local authorTween = TweenService:Create(clone.Main.Author, info, {TextTransparency = 0})
		local titleTween = TweenService:Create(clone.Main.Title, info, {BackgroundTransparency = 0, TextTransparency = 0})
		local descriptionTween = TweenService:Create(clone.Main.Description, info, {BackgroundTransparency = 0, TextTransparency = 0})
		
		clone.Parent = v.PlayerGui
		clone.Main.Author.Text = "Announcement By: " .. request.author
		clone.Main.Title.Text = request.title
		clone.Main.Description.Text = request.description
		
		authorTween:Play()
		titleTween:Play()
		descriptionTween:Play()
		dividerTween:Play()
		mainTween:Play()
		closeTween:Play()
	end
	
	game:GetService("HttpService"):RequestAsync({
		Url = _G.baseReplUrl .. _G.verifyRequestEndpoint,
		Method = "POST",
		Headers = {
			["Content-Type"] = "application/json",
			["success"] = "true",
			["message"] = "I've successfully announced this to the game"
		}
	})
end

I’m surprised how this isn’t working as shouldn’t all servers be getting the request?

Remember that not all scripts start at the EXACT same time, meaning they do not check the request all at the same time. It’s also best to raise how often you check a request, as Rate Limiting is a thing and could be a reason to why you aren’t getting the request back.

To fix the issue of them not getting it at the exact same time, use MessagingService:PublishAsync() and MessagingService:Subscribe() to send a message to all other message subscribers. Find more information about those below:

MessagingService

What stopping the server from Publishing multiple times?

Nothing would be stopping the server from publishing to others multiple times. I would recommend creating a variable to keep track of the current message, and update whenever it checks the request or gets a new message from other servers. Here is an example of this below:

local CurrentMessage = ""

local MessageService = game:GetService("MessagingService")

MessageService:SubscribeAsync("NEWMESSAGE", function(Response)
    local Message = Response["Data"] -- Message Callbacks with a table filled with the Data and the time of which the message was sent.

    if Message == CurrentMessage then return end -- Stop the thread from running.

    CurrentMessage = Message
    adminSystem:Run()
end)

-- Whenever the new message is detected, send a message to other servers:
if NewMessage ~= CurrentMessage then
    MessageService:PublishAsync("NEWMESSAGE", "TestAnnouncement")
end

Once again, this is only an example. Modify it to what your script uses.

I’m still confused though, where should I put the Publish/Subscribe stuff?

Okay, I think I figured it out, but when it’s about to announce, it gets an error saying that it’s trying to index author with nil even though I send the request object with PublishAsync and on the game that does announce it, it says that getn expected a table, and it got nil.

This is my code

local MessageService = game:GetService("MessagingService")
local TweenService = game:GetService("TweenService")
local PlayerService = game:GetService("Players")

function isEqual(table1, table2)
	if _G.request == nil then return false end
	if table.getn(table1) ~= table.getn(table2) then return false end
	for i,v in pairs(table1) do
		if table1[i] ~= table2[i] then return false end
	end
	return true
end

MessageService:SubscribeAsync("Announcement", function(res)
	local data = res.data
	
	if isEqual(_G.request, data) == true then return end
	
	local info = TweenInfo.new(
		3,
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)
	
	for _,v in pairs(PlayerService:GetPlayers()) do
		local clone = script.Parent["Announcement GUI"]:Clone()

		local mainTween = TweenService:Create(clone.Main, info, {BackgroundTransparency = 0})
		local dividerTween = TweenService:Create(clone.Main.Divider, info, {BackgroundTransparency = 0})
		local closeTween = TweenService:Create(clone.Main.Close, info, {BackgroundTransparency = 0, TextTransparency = 0})
		local authorTween = TweenService:Create(clone.Main.Author, info, {TextTransparency = 0})
		local titleTween = TweenService:Create(clone.Main.Title, info, {BackgroundTransparency = 0, TextTransparency = 0})
		local descriptionTween = TweenService:Create(clone.Main.Description, info, {BackgroundTransparency = 0, TextTransparency = 0})

		clone.Parent = v.PlayerGui
		clone.Main.Author.Text = "Announcement By: " .. data.author
		clone.Main.Title.Text = data.title
		clone.Main.Description.Text = data.description

		authorTween:Play()
		titleTween:Play()
		descriptionTween:Play()
		dividerTween:Play()
		mainTween:Play()
		closeTween:Play()
	end
end)

Top one is the one for if announcement doesn’t show up and bottom one is the one where it does show up
https://gyazo.com/108afee1ecfb7a29c0ffc8ffc201252e

Fixed, changed res.data to res.Data