local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")
local Admins = { "Cookie12bo", "Mrpenguin892"}
local function IsAdmin(Player)
for _, AdminName in ipairs(Admins) do
if string.lower(Player.Name) == string.lower(AdminName) then
return true
end
end
return false
end
local function AddAdmin(PlayerName)
if not table.find(Admins, PlayerName) then
table.insert(Admins, PlayerName)
Announce(PlayerName .. " has been added as an admin!")
else
Announce(PlayerName .. " is already an admin!")
end
end
local function RemoveAdmin(PlayerName)
for i, AdminName in ipairs(Admins) do
if string.lower(AdminName) == string.lower(PlayerName) then
table.remove(Admins, i)
Announce(PlayerName .. " has been removed from admin!")
return
end
end
Announce(PlayerName .. " is not an admin!")
end
local function Announce(Message)
for _, Player in ipairs(Players:GetPlayers()) do
Player:SendMessage("ANNOUNCEMENT: " .. Message)
end
StarterGui:SetCore("SendNotification", {
Title = "ANNOUNCEMENT";
Text = Message;
Duration = 5;
})
end
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Msg)
local Args = string.split(Msg, " ")
local Command = string.lower(Args[1])
if IsAdmin(Player) then
if Command == ":addadmin" and Args[2] then
AddAdmin(Args[2])
elseif Command == ":removeadmin" and Args[2] then
RemoveAdmin(Args[2])
elseif Command == ":announce" and Args[2] then
local Message = table.concat(Args, " ", 2)
Announce(Message)
end
end
end)
end)