-- [[admin commands
make a script inside serverscriptservice and put this in it]]
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TeleportService = game:GetService("TeleportService")
local RestartBindable = [Link]("BindableEvent")
[Link] = "RestartServers"
[Link] = ReplicatedStorage
local AdminUsername = "BlackDude45782" -- replace with your user
local BannedUsers = {}
local function getPlayerByNameOrDisplay(name)
for _, player in ipairs(Players:GetPlayers()) do
if [Link]:lower() == name:lower() or [Link]:lower() ==
name:lower() then
return player
end
end
end
local function isAdmin(player)
return [Link] == AdminUsername
end
local function handleCommand(player, message)
if not isAdmin(player) then return end
local args = message:split(" ")
local cmd = args[1]:lower()
if cmd == "/ban" and args[2] and args[3] then
local targetName = args[2]
local duration = tonumber(args[3]) or 1
local targetPlayer = getPlayerByNameOrDisplay(targetName)
if targetPlayer then
if targetPlayer == player then
player:SendNotification({
Title = "Error",
Text = "You Cannot Ban Yourself",
Duration = 2
})
else
local realName = [Link]
BannedUsers[realName:lower()] = {
banner = [Link],
duration = duration,
}
targetPlayer:Kick("You Have Been Banned By " .. [Link]
.. " For " .. duration .. " Hour(s)")
end
end
elseif cmd == "/unban" and args[2] then
for name, _ in pairs(BannedUsers) do
if name == args[2]:lower() then
BannedUsers[name] = nil
end
end
elseif cmd == "/clearbans" then
BannedUsers = {}
elseif cmd == "/kick" and args[2] then
local target = getPlayerByNameOrDisplay(args[2])
if target then
if target == player then
player:SendNotification({
Title = "Error",
Text = "You Cannot Kick Yourself",
Duration = 2
})
else
target:Kick("You have been kicked by admin.")
end
end
elseif cmd == "/kickall" then
for _, p in ipairs(Players:GetPlayers()) do
if p ~= player then
p:Kick("Server restart or admin kick.")
end
end
elseif cmd == "/shutdownglobal" then
local shutdownMessage = "Servers Shutdown By " .. [Link]
RestartBindable:Fire()
for _, p in ipairs(Players:GetPlayers()) do
p:Kick(shutdownMessage)
end
elseif cmd == "/shutdownlocal" then
local shutdownMessage = "This Server Has Been Shutdown By " ..
[Link]
for _, p in ipairs(Players:GetPlayers()) do
p:Kick(shutdownMessage)
end
elseif cmd == "/restartlocal" then
for _, p in ipairs(Players:GetPlayers()) do
TeleportService:Teleport([Link], p)
end
elseif cmd == "/restartglobal" then
local restartMessage = "Servers Shutdown By " .. [Link]
RestartBindable:Fire()
for _, p in ipairs(Players:GetPlayers()) do
if p and [Link] then
TeleportService:Teleport([Link], p)
end
end
elseif cmd == "/goto" and args[2] then
local target = getPlayerByNameOrDisplay(args[2])
if target then
[Link]:MoveTo([Link])
end
elseif cmd == "/tp" and args[2] then
local target = getPlayerByNameOrDisplay(args[2])
if target then
[Link]:MoveTo([Link])
end
end
end
[Link]:Connect(function(player)
local banData = BannedUsers[[Link]:lower()]
if banData then
local msg = "You Have Been Banned By " .. [Link] .. " For " ..
[Link] .. " Hour(s). Reason: " .. [Link]
player:Kick(msg)
end
[Link]:Connect(function(message)
handleCommand(player, message)
end)
end)
game:BindToClose(function()
for i, v in pairs([Link]:GetPlayers()) do
if [Link] == 18444582450 then
if not [Link](AccessList, [Link]) then
continue
end
end
ServerUtils:UnregisterPlayer(v)
end
end)