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

How do I send data from one server to the other?

Asked by 7 years ago

I have always wondered how servers can send stuff between them. For example Miners Haven with their shout feature that allows people to talk in different server. I am not asking for a script I am just wondering how this works

0
datastore Async_io 908 — 7y

1 answer

Log in to vote
0
Answered by
DevNetx 250 Moderation Voter
7 years ago

This is done by using datastores.

In one server, a function is run to set the value of a datastore.

Then, on the other, there is an OnUpdate function which is triggered once the value is set.

For Example:

Server 1:

local DataStore = game:GetService("DataStoreService"):GetDataStore("CrossChat") -- get the datastore

function MyEpicChatFunction(message,player)
    message = game.Chat:FilterStringForBroadcast(message, player) -- remember to filter!
    DataStore:SetAsync("Chat",message) -- Sets the "Chat" value to the message
end

Server 2:

local DataStore = game:GetService("DataStoreService"):GetDataStore("CrossChat") -- get the datastore

local MyConnection = DataStore:OnUpdate("Chat",function(message) -- set up the function
    local hint = Instance.new("Hint",workspace) -- create a hint
    hint.Text = message -- set the text of the hint
    wait(2) -- Wait for two seconds
    hint:Destroy() -- Remove the hint
end)

This is a crude example, but would probably work.

0
oh ok. That makes sence User#15461 0 — 7y
Ad

Answer this question