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

How do I make something that happens in every server? (Globally)

Asked by 8 years ago

Like for example, a Global Message Shout, or a Global Shutdown Message?

1 answer

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

DataStores

Probably the worst way you could do this would be using DataStores, mainly because of their request liimit. It is something like NumPlayers*10+60. The only way you would be able to use this feature is using a loop constantly checking a value, in intervals of around 30 seconds to a minute.

E.G;

function setGuis(message) -- function for setting the message
    for _,v in pairs (game.Players:GetPlayers()) do -- iterates through players
        local text = v.PlayerGui.MessageGui.Message -- gets the gui to change
        if message then -- if there is a message
            text.Visible = true -- shows gui
            text.Text = message -- sets text
        else
            text.Visible = false -- hides gui
            text.Text = "" -- removes text
        end
    end
end

local ds = game:GetService("DataStoreService"):GetDataStore("GlobalMessage") -- gets DataStore
local key = "message" -- gets a key for the DataStore

function setGlobalMessage(msg) -- sets the global message
    ds:SetAsync(key,msg)-- sets the message
end

while wait(60) do -- repeats indefinately
    local msg = ds:GetAsync(key) -- gets the message
    setGuis(msg) -- updates guis
end

P.S:

Maybe it isn't as bad as I made it out. It can just be flawed at times, and the request limit isn't so bad when you look at it.


Trello/Other Service

I don't believe there is a request limit for HTTP, so you can use it trello and other services in the same manner I made above.

I haven't tried to use this before, so I can't really help you, but a google search can help you with that. SH also has a useful blog post on that: https://scriptinghelpers.org/blog/logging-errors-with-trello


Hope I helped!

~TDP

Ad

Answer this question