OnUpdate Doesn't Announce Globally

So I’ve been trying to make this announcement thing where you can send an announcement worldwide (admins only) as a changelog.
I’ve tried to use OnUpdate for this, and it worked perfectly. That is, until I found out it was limited to one server…
I got a friend of mine to help me test out this theory (the game will be 200 player servers, tested it on two singleplayer servers), and of course, it’s only on one server.
Update Script:

function D()
	spawn(function()
		print("Update")
		local Tab = MessageServ:GetAsync("News")
		if Tab then
			if Tab ~= PrevTab then
				PrevTab = Tab
				local Table = Decode(Tab)
				for _,v in pairs(game.Players:GetPlayers()) do
					spawn(function()
						--You get the point. Change log things.
					end)
				end
			end
		end
	end)
end

Since then, I’ve had to use an annoying get async loop.

Am I doing something wrong? Or is OnUpdate just a bit broken at this moment in time?

Any help is appreciated on this matter.

Use the new MessagingService API to allow servers to communicate with one another. Here’s a tutorial on it.

1 Like

I know how to use MessagingService, but the thing is it’s only limited to 80 characters (i think). I’m talking about a whole changelog full of more than 80 characters.
It has a title and a body.

You’re right, there is an 80 character limit on the data that you can send and receive, as seen in the wiki:

Topics are developer defined strings (1-80 characters) that game servers can send and receive messages.

The bug with OnUpdate is known and is yet to be fixed- a staff member mentioned here that it won’t be prioritised due to the new MessagingService.

Here’s my solution. I would use MessagingService with DataStores.

  • An admin fires a remote event with the title and body of the announcement
  • The server saves the announcement to a datastore, with the key being a unique ID, perhaps using os.time() or tick(), and the value being a dictionary of the title and body of the announcement. Add a cooldown to how frequent an admin can publish an announcement to prevent spam
  • MessagingService is then used to notify the rest of the servers that an announcenent has been published, with the data being the unique ID of the announcement
  • When the other servers receive the message, they get the data from the DataStore using the unqiue ID in the message received, then the announcement is shown using the data
3 Likes

Use a combination of a DataStore and MessagingService. Push the changelog to the DataStore, then send an announcement that the key has been updated via MessagingService.

5 Likes

Thank you for the solutions. I’ll try them and get back as fast as possible.

This solution worked wonderfully. Never thought of using os.time().
There’s also a debounce on the publish announcement GUI, so there’s no need to worry about admin spam.
Thanks for your help.

1 Like

I just realised that I’m wrong. The limit applies to the topic and not the data that you can send.
The data limit for messages is 1kB, as seen in this post:

MessagingService limits

Message size: 1kB
Messages per game server per minute: 150 + 60 * number of players
Subscriptions per game server : 5 + 2 * number of players
Subscriptions per game universe : 10,000

1kB should be 1 thousand characters, so you would still have to use datastores if you want to be able to send announcements that could have over a thousand characters.
(I tested the character limit on strings. The maximum amount of characters I could store before receiving an error was 974)

1 Like