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

How to make a global message? (A message that spreads over all servers)

Asked by
Derzett 51
5 years ago

Hey so i've been looking on how to make a global message for ex. When the game shutdowns but i couldn't find anything. All i need is atleast a method to spread something globally and that's all.

1 answer

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

If you're going to make a message that can be customized and fire anytime then i might have the answer.

Short answer: Data stores. Longer answer: Create a data store system with a string value that'll replicate onto other servers.

Example:

local dss = game:GetService(DataStoreService)
local messageDS = dss:GetDataStore("msg")
while true do 
    wait(5) -- update interval
    print(messageDS:GetAsync("globalMessage")) -- you can set the key to whatever you like
end

This is just the premise and you can of course remove the while loop and instead port this to a gui but this is just an example.

Now it'll print nil (since we haven't set the value yet) every 5 seconds. Setting it to a value is actually quite easy.

local dss = game:GetService(DataStoreService)
local messageDS = dss:GetDataStore("msg")
function newMessage(text)
    messageDS:SetAsync("globalMessage",text)
end

There might be more efficient methods but this is just what i have.

And also make sure you've enabled API services in your game.

Ad

Answer this question