Skip to content

Instantly share code, notes, and snippets.

@Embedded77
Last active January 24, 2021 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Embedded77/9ef68aa8712f5ecf88a24da6aec1ee2a to your computer and use it in GitHub Desktop.
Save Embedded77/9ef68aa8712f5ecf88a24da6aec1ee2a to your computer and use it in GitHub Desktop.

This gist is an example of how to use EMS

Create a RemoteEvent in ReplicatedStorage and name it "Announcements" Create a localscript in startergui Create a serverscript in serverscriptservice Get the EMS module and put it in serverstorage

MAKE SURE YOU HAVE A TOKEN

game.ReplicatedStorage.Announcements.OnClientEvent:Connect(function(message)
game:GetService("StarterGui"):SetCore("SendNotification",{
Title="Announcement",
Text=message,
Button1="OK",
Duration=3,
})
end)
local ems=require(game.ServerStorage.EMS).new("Your Token Here")
local admins={["youruseridhere"]=true}
ems:Begin(1)()
ems:Subscribe("Announcements",function(message)
game.ReplicatedStorage.Announcements:FireAllClients(message.author.." says '"..message.content.."'. ")
end)
game.Players.PlayerAdded:Connect(function(plr)
wait(1)
print(admins[plr.UserId..""])
if admins[plr.UserId..""] then
plr.Chatted:Connect(function(msg)
local args=msg:split(" ")
print(args)
if(args[1]=="!g_announce") then
args[1]=""
local s=""
for i,v in pairs(args) do
if v~="" then
s=s..(v.." ")
end
end
s:sub(1,s:len()-1)
print(s)
print(ems:Post("Announcements",s,plr.Name))
end
end)
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment