Sending Data Between a Server and a Reserved Server

Hello! I am making a party system for my game currently and I already have a good amount done but I’m wondering how I can send a message/data from one server to another server which is a reserved server. I already have a system set up for storing the access keys for the reserved servers, so I’m wondering how I can use the access key to send information to that reserved server. (Sorry if this is convoluted, I just don’t really know how else to word it).

1 Like

You can utilize MessagingService; it was created for Cross-Server communication

I know about MessagingService, the problem is, the documentation is kind of confusing and doesn’t really explain how to send information to just one server.

It’s sends information to all the servers. For only one server to communicate, just send a MessagingService event with the key information and detect if the key is the same from the reserved server:

-- Event subscription
game:GetService("MessagingService"):SubscribeAsync("TOPIC_NAME", function(data)
   local eventData = data.Data -- the content sent from the signal
   -- you can send a table through the event with the key provided

   if eventData.Key == "ReservedServerKey" then
     -- do things
   end
end)
2 Likes

Thank you so much! I don’t know how I didn’t even think of this before. It’s basically the same process as using a remote event now that I realize.

2 Likes

There’s nothing wrong with your code, it’s probably just me, but for some reason when I send the message the key just returns as nil, which didn’t happen when I tested the key by printing it.

1 Like

Interesting how that works for you, one time I followed a tutorial on MessagingService and it wouldn’t even log out anything…

Nevermind, I just ended up finding a way to do it using datastores.

Various TeleportService instance methods allow you to transmit additional data with the teleport request.

I figured out how to do it using a datastore key that is checked using GetASync every 5-10 seconds (to not fill datastore requests) that is changed using SetAsync to the invitee’s reserved server access code if somebody submits a username into the invite section. Everytime the key has been detected as changed, a ui shows up on the invited persons giving them the option to join the party, which then teleports them to the invitee’s lobby/reserved server using the access code. It actually works pretty well with only the very little downside of the invite being delayed 5-10 seconds on the invited person’s screen.

1 Like