Hi, i was looking tho the roblox services and i found MessagingService. I thought it was a messaging to a player service but actually is a server-going message.
i made a example script:
local MessagingService = game:GetService("MessagingService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Admins = require(script.Parent.SettingsAdmin).Ranks -- Getting the IDS for admins
function IsAdmin(player)
for _, v in pairs(Admins) do
if Admins == player then
return true
end
end
return false
end
game.Players.PlayerAdded:Connect(function(plr)
if IsAdmin(plr.UserId) == true then
local gui = game:GetService("ServerStorage").GUIS.AdminGUI:Clone()
gui.Parent = plr.PlayerGui
plr.PlayerGui.ChildAdded:Connect(function(child)
if child:IsA("ScreenGui") and child.Name == script.AdminGUI.Name and IsAdmin(plr) == false then
plr:Kick("Reason: \n Exploiting to AdminScreen. \n Kicked By System")
end
end)
end
end)
ReplicatedStorage.Remotes.MessageEvent.OnServerEvent:Connect(function(plr, message)
MessagingService:PublishAsync("Global Message", message)
print(message.Data)
end)
MessagingService:SubscribeAsync("Global Message", function()
-- Empty
end)
I dont know what to put in MessagingService:SubscribeAsync’s Function
if you know, please tell in the comments