Admin Panel v3 Update
The original topic has been updated with the new link.
Hello everyone! I have now released version 3 of my admin panel, version 2 of the Admin Permission Handler, and finalized version 1 of the Remote Events. Hope you all enjoy!
For the scripters amongst us, here is the original, unorganized script, and the new, enhanced script.
Original Script
local groupId = 0 -- Change this to your groupId number
local minimumRankToView = 0 -- Change this to the rankId of the MINIMUM rank who can view the admin panel
local minimumBanRank = 0 -- Change this to the minimum rank to ban a player.
local minimumKickRank = 0 -- Change this to the minimum rank to kick a player.
local minimumRespawnRank = 0 -- Change this to the minimum rank to respawn a player.
local minimumRebootRank = 0 -- Change this to the minimum rank to reboot the server.
local minimumWarnRank = 0 -- Change this to the minimum rank to warn a player.
local Update = "" -- Message Displayed when the PutIntoStarterGui server is updating.
local Reserved = "" -- Message Displayed in the lobby server.
local gameName = "" -- Change to the name of the game.
game.Players.PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup(groupId) >= minimumRankToView then
local PutIntoStarterGui = plr.PlayerGui:WaitForChild("PutIntoStarterGui")
PutIntoStarterGui.AdminButton.Visible = true
end
end)
local function banUser(banningPlayer, kickPlayer, rsn, banTime)
if game.Players:FindFirstChild(kickPlayer):GetRankInGroup(groupId) < game.Players:FindFirstChild(banningPlayer.Name):GetRankInGroup(groupId) and banningPlayer:GetRankInGroup(groupId) >= minimumBanRank then
print(banningPlayer, kickPlayer, rsn, banTime)
local dataStore = game:GetService("DataStoreService")
local bansStore = dataStore:GetDataStore("Bans")
bansStore:SetAsync(kickPlayer.."user", kickPlayer)
bansStore:SetAsync(kickPlayer.."reason", rsn)
bansStore:SetAsync(kickPlayer.."status", true)
game.Players:FindFirstChild(kickPlayer):Kick("You are banned from "..gameName..".\nReason: "..rsn.."\n You will be unbanned in "..banTime.." day(s)")
local currentBanTime = os.time()
local daysToSecs = banTime * 86400
local timeAtUnban = tonumber(currentBanTime) + tonumber(daysToSecs)
bansStore:SetAsync(kickPlayer.."time", banTime)
bansStore:SetAsync(kickPlayer.."timeAtUnban", timeAtUnban)
print("!!BAN LOG!!", kickPlayer, "was banned for", rsn, "and will be unbanned in", banTime, "day(s)")
local action = "Ban Length: "..banTime.." day(s)"
local banningPlayerName = banningPlayer.Name
game.ReplicatedStorage.AddLog:FireAllClients(banningPlayerName, action, kickPlayer)
else
banningPlayer.PlayerGui.PutIntoStarterGui.BanPanel.BanPlayer.Text = "Insufficient Permissions!"
wait(1)
banningPlayer.PlayerGui.PutIntoStarterGui.BanPanel.BanPlayer.Text = "Ban Player"
end
end
game.Players.PlayerAdded:Connect(function(plr)
local usr = plr.Name
local dataStore = game:GetService("DataStoreService")
local bansStore = dataStore:GetDataStore("Bans")
local usr = bansStore:GetAsync(usr.."user")
local banStatus = bansStore:GetAsync(usr.."status")
local banReason = bansStore:GetAsync(usr.."reason")
local timeAtUnban = bansStore:GetAsync(usr.."timeAtUnban")
local banTimeRemaining = bansStore:GetAsync(usr.."time")
local currentTime = os.time()
if banStatus == true and usr == plr.Name and timeAtUnban > currentTime then
plr:Kick("You are banned from "..gameName..".\nReason: "..banReason.."\n You will be unbanned in "..banTimeRemaining.." day(s)")
else
return false
end
end)
game.ReplicatedStorage.BanUser.OnServerEvent:Connect(banUser)
local function kickPlayer(kickingPlayer, kickPlayer, rsn)
if game.Players:FindFirstChild(kickPlayer):GetRankInGroup(groupId) < game.Players:FindFirstChild(kickingPlayer.Name):GetRankInGroup(groupId) and kickingPlayer:GetRankInGroup(groupId) >= minimumKickRank then
local plr = game.Players:WaitForChild(kickPlayer)
local kickerName = kickingPlayer.Name
plr:Kick("You have been kicked from this game by "..kickerName..".\n You were kicked with a reason of "..rsn..".")
local action = "Kick"
local kickingPlayerName = kickingPlayer.Name
game.ReplicatedStorage.AddLog:FireAllClients(kickingPlayerName, action, kickPlayer)
else
kickingPlayer.PlayerGui.PutIntoStarterGui.KickPanel.KickPlayer.Text = "Insufficient Permissions!"
wait(1)
kickingPlayer.PlayerGui.PutIntoStarterGui.KickPanel.KickPlayer.Text = "Kick Player"
end
end
game.ReplicatedStorage.KickUser.OnServerEvent:Connect(kickPlayer)
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
if (game.VIPServerId ~= "" and game.VIPServerOwnerId == 0) then
local m = Instance.new("Message")
m.Text = Reserved
m.Parent = workspace
local waitTime = 5
Players.PlayerAdded:connect(function(player)
wait(waitTime)
waitTime = waitTime / 2
TeleportService:Teleport(game.PlaceId, player)
end)
for _,player in pairs(Players:GetPlayers()) do
TeleportService:Teleport(game.PlaceId, player)
wait(waitTime)
waitTime = waitTime / 2
end
else
game.ReplicatedStorage.ShutdownServer.OnServerEvent:Connect(function()
if (#Players:GetPlayers() == 0) then
return
end
if (game:GetService("RunService"):IsStudio()) then
return
end
local m = Instance.new("Message")
m.Text = Update
m.Parent = workspace
wait(2)
local reservedServerCode = TeleportService:ReserveServer(game.PlaceId)
for _,player in pairs(Players:GetPlayers()) do
TeleportService:TeleportToPrivateServer(game.PlaceId, reservedServerCode, { player })
end
Players.PlayerAdded:connect(function(player)
TeleportService:TeleportToPrivateServer(game.PlaceId, reservedServerCode, { player })
end)
while (#Players:GetPlayers() > 0) do
wait(1)
end
end)
end
local function respawnPlayer(localPlayer, respawnPlayer)
if localPlayer:GetRankInGroup(groupId) >= minimumRespawnRank then
local respawnPlayer = game.Players:FindFirstChild(respawnPlayer)
respawnPlayer.Character.Humanoid.Health = 0
local action = "Respawn"
local respawningPlayerName = localPlayer.Name
local respawnPlayerName = respawnPlayer.Name
game.ReplicatedStorage.AddLog:FireAllClients(respawningPlayerName, action, respawnPlayerName)
end
end
game.ReplicatedStorage.RespawnPlayer.OnServerEvent:Connect(respawnPlayer)
local function unban(admin, bannedUser)
local adminName = admin.Name
local dataStore = game:GetService("DataStoreService")
local bansStore = dataStore:GetDataStore("BansStore")
bansStore:SetAsync(bannedUser.."status", false)
local action = "Unban"
local unbanningPlayerName = admin.Name
game.ReplicatedStorage.AddLog:FireAllClients(unbanningPlayerName, action, bannedUser)
end
game.ReplicatedStorage.UnbanPlayer.OnServerEvent:Connect(unban)
local function warnUser(localPlayer, warnedPlayer, rsn)
if game.Players:FindFirstChild(warnedPlayer):GetRankInGroup(groupId) < game.Players:FindFirstChild(localPlayer.Name):GetRankInGroup(groupId) and game.Players:FindFirstChild(localPlayer.Name):GetRankInGroup(groupId) >= minimumKickRank then
local plr = game.Players:WaitForChild(warnedPlayer)
local warnerName = localPlayer.Name
local PlayerGui = plr.PlayerGui.PutIntoStarterGui
PlayerGui.WarningPrompt.Visible = true
PlayerGui.WarningPrompt.TextLabel.Text = "Warning: You have been warned by "..localPlayer.Name.." with a reason of "..rsn.."."
local action = "Warn"
game.ReplicatedStorage.AddLog:FireAllClients(warnerName, action, warnedPlayer)
else
localPlayer.PlayerGui.PutIntoStarterGui.WarnPanel.WarnPlayer.Text = "Insufficient Permissions!"
wait(1)
localPlayer.PlayerGui.PutIntoStarterGui.WarnPanel.WarnPlayer.Text = "Kick Player"
end
end
game.ReplicatedStorage.WarnUser.OnServerEvent:Connect(warnUser)
New, Enhanced Script
local groupId = 0 -- Change this to your groupId number
local minimumRankToView = 0 -- Change this to the rankId of the MINIMUM rank who can view the admin panel
local developerRank = 0 -- Change this to the rankId of the MINIMUM rank who can Reboot the server and have access to developer tools.
local gameName = "Testing" -- Change to the name of the game.
local DataStoreService = game:GetService("DataStoreService")
local BansStore = DataStoreService:GetDataStore("BansStore")
local Players = game:GetService("Players")
-- Ban Check & Admin Check --
game.Players.PlayerAdded:Connect(function(plr)
local UserId = plr.UserId
if BansStore:GetAsync(UserId.."-isBanned") == true then
local BanReason = BansStore:GetAsync(UserId.."-banReason")
local TimeAtUnban = BansStore:GetAsync(UserId.."-timestampAtUnban")
local TimeNow = os.time()
if TimeNow < TimeAtUnban then
local DaysUntilUnban = TimeAtUnban - TimeNow
local PreFormattedDaysUntilUnban = DaysUntilUnban / 86400
local FormattedDaysUntilUnban = math.floor(PreFormattedDaysUntilUnban + 0.5)
plr:Kick("You have been banned from "..gameName.." for the reason of "..BanReason..".\n\n You will be unbanned in "..FormattedDaysUntilUnban.." day(s).")
warn(plr.Name.." attempted to join the game, they were kicked: User is Banned")
else
return false
end
end
end)
game.Players.PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup(groupId) >= minimumRankToView then
local PutIntoStarterGui = plr.PlayerGui:WaitForChild("PutIntoStarterGui")
PutIntoStarterGui.AdminButton.Visible = true
else
return false
end
end)
-- Ban User --
game.ReplicatedStorage.BanUser.OnServerEvent:Connect(function(moderator, usernameToBan, reason, daysToBan)
local playerToBan = Players:FindFirstChild(usernameToBan)
local moderatorUsername = moderator.Name
local IdToBan = playerToBan.UserId
if playerToBan:GetRankInGroup(groupId) < moderator:GetRankInGroup(groupId) then
local timeToAdd = daysToBan * 86400
local timestampAtUnban = timeToAdd + os.time()
BansStore:SetAsync(IdToBan.."-isBanned", true)
BansStore:SetAsync(IdToBan.."-banReason", reason)
BansStore:SetAsync(IdToBan.."-timestampAtUnban", timestampAtUnban)
local action = "Ban Length: "..daysToBan.." day(s)"
game.ReplicatedStorage.AddLog:FireAllClients(moderatorUsername, action, usernameToBan)
playerToBan:Kick("You have been banned from "..gameName.." for the reason of "..reason..".\n\n You will be unbanned in "..daysToBan.." day(s).")
else
moderator.PlayerGui.PutIntoStarterGui.BanPanel.BanPlayer.Text = "Insufficient Permissions!"
wait(1)
moderator.PlayerGui.PutIntoStarterGui.BanPanel.BanPlayer.Text = "Ban Player"
end
end)
-- Kick User --
game.ReplicatedStorage.KickUser.OnServerEvent:Connect(function(moderator, usernameToKick, reason)
local playerToKick = Players:FindFirstChild(usernameToKick)
local moderatorUsername = moderator.Name
if playerToKick:GetRankInGroup(groupId) < moderator:GetRankInGroup(groupId) then
local action = "Kick"
game.ReplicatedStorage.AddLog:FireAllClients(moderatorUsername, action, usernameToKick)
playerToKick:Kick("You have been kicked from "..gameName.." for the reason of "..reason..".")
else
moderator.PlayerGui.PutIntoStarterGui.KickPanel.KickPlayer.Text = "Insufficient Permissions!"
wait(1)
moderator.PlayerGui.PutIntoStarterGui.KickPanel.KickPlayer.Text = "Kick Player"
end
end)
-- Respawn Player --
game.ReplicatedStorage.RespawnPlayer.OnServerEvent:Connect(function(moderator, usernameToRespawn)
local playerToRespawn = Players:FindFirstChild(usernameToRespawn)
local moderatorUsername = moderator.Name
if playerToRespawn:GetRankInGroup(groupId) < moderator:GetRankInGroup(groupId) then
local Humanoid = playerToRespawn.Character.Humanoid
Humanoid.Health = 0
local action = "Respawn"
game.ReplicatedStorage.AddLog:FireAllClients(moderatorUsername, action, usernameToRespawn)
else
moderator.PlayerGui.PutIntoStarterGui.RespawnPanel.RespawnPlayer.Text = "Insufficient Permissions!"
wait(1)
moderator.PlayerGui.PutIntoStarterGui.RespawnPanel.RespawnPlayer.Text = "Respawn Player"
end
end)
-- Unban Player --
game.ReplicatedStorage.UnbanPlayer.OnServerEvent:Connect(function(moderator, usernameToUnban)
if moderator:GetRankInGroup(groupId) >= minimumRankToView then
local IdToUnban = Players:GetUserIdFromNameAsync(usernameToUnban)
local moderatorUsername = moderator.Name
BansStore:RemoveAsync(IdToUnban.."-isBanned")
print(usernameToUnban.." was unbanned at "..os.time().." by "..moderatorUsername..".")
local action = "Unban"
game.ReplicatedStorage.AddLog:FireAllClients(moderatorUsername, action, usernameToUnban)
else
moderator.PlayerGui.PutIntoStarterGui.UnbanPanel.UnbanPlayer.Text = "Insufficient Permissions!"
wait(1)
moderator.PlayerGui.PutIntoStarterGui.UnbanPanel.UnbanPlayer.Text = "Unban Player"
end
end)
-- Warn Player --
game.ReplicatedStorage.WarnUser.OnServerEvent:Connect(function(moderator, usernameToWarn, reason)
local playerToWarn = Players:FindFirstChild(usernameToWarn)
if moderator:GetRankInGroup(groupId) >= minimumRankToView then
local moderatorUsername = moderator.Name
game.ReplicatedStorage.ClientWarnUser:FireClient(playerToWarn, moderatorUsername, reason)
local action = "Warn"
game.ReplicatedStorage.AddLog:FireAllClients(moderatorUsername, action, usernameToWarn)
else
moderator.PlayerGui.PutIntoStarterGui.WarnPanel.WarnPlayer.Text = "Insufficient Permissions!"
wait(1)
moderator.PlayerGui.PutIntoStarterGui.WarnPanel.WarnPlayer.Text = "Warn Player"
end
end)
-- Shutdown Server --
game.ReplicatedStorage.ShutdownServer.OnServerEvent:Connect(function(developer)
if developer:GetRankInGroup(groupId) >= developerRank then
for _,v in pairs(Players:GetChildren()) do
v:Kick("We are so sorry to interrupt your experience, but a game developer has shutdown the game.\n\n Please try rejoining a different server.")
end
end
end)