Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to send data from the server of one place to the server of another place?

Asked by 4 years ago

The goal of my task in mind is to teleport an unknown number of players from one place to another, and communicate to the destination place how many people have teleported

With TeleportService, all of the functionality I've seen is for sending data to the Client for each player (TeleportService:GetLocalPlayerTeleportData), but this information is needed for the server of my destination place...

A solution I've thought of is to set the LocalPlayerTeleportData of each player, then have the each client fire an event to pass the LocalPlayerTeleportData to the server. The server would only save the value for the first server event fired... but this seems like a hacky way to do this.

Any tips would be appreciated, thanks!

0
globaldatastore? iiDev_Hunt3r 64 — 4y
0
iiDev_Hunt3r, I do not believe that you understand what a GlobalDataStore is. A GlobalDataStore, is just a normal DataStore, and just doesn't require using the "GetDataStore" method of DataStoreService. DataStores are also, altogether, an unnecessary method of transmitting data through servers. OptimisticSide 199 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

To achieve this, you'll need to utilize ROBLOX's MessagingService. This allows messages to be sent from one server to another. MessagingService uses Topics, which are channels that servers can post and listen for data to be transmitted through.

There are two main methods of MessagingService.

The first one is PublishAsync. This takes two parameters: the topic's name, and the data to be sent.

The next method is SubscribeAsync. This takes only one parameter, which is the topic's name. This will return a RBXScriptSignal, which can be connected to just as any other event.

I've made a quick example that will print whenever a player joins a game.

local ChannelName = "PlayerJoins"

local MessagingService = game:GetService("MessagingService")
local Players = game:GetService("Players")


MessagingService:SubscribeAsync(ChannelName):Connect(function(PlayerName)
    print(PlayerName .. " has just joined a server of this game!")
end)

Players.PlayerAdded:Connect(function(Player)
    MessagingService(ChannelName, Player.Name)
end)


0
Thanks! Hycheese 34 — 4y
Ad

Answer this question