I'm currently making a custom admin script and it was all going well until I realised that everything I said killed me. This is my script:
local Admins = {"robloxianmirror", "Player", "Player1"}
local Prefix = "#"
local Banned = {"Bad_Guy123"}
--[[
"Me" isn't implemented yet however "[Prefix]kill all" will work
Current commands:
Manual Ban Via script
shutdown - Shutsdown the server
kill - Kills a player
damage - Takes of 10% of a player's health
--]]
game.Players.PlayerAdded:connect(function(Player) -- Bans
for l, a in pairs(Banned) do
if Player.Name == Banned[l] then
Player:Kick("You are banned from this game.")
end
end
end)
game.Players.PlayerAdded:connect(function(Player) -- Check for Admin
for i, v in pairs (Admins) do
if Player.name == Admins[i] then
local Location = Player.PlayerGui
local Gui = script.ScreenGui:Clone()
Gui.Parent = Location
Gui.Frame.Text.Text = "Welcome " .. Player.Name .. ", you are an admin!"
Gui.Frame:TweenPosition(UDim2.new(0.333, 0 ,0 ,0), "In", "Quad", 0.75)
wait(3)
Gui.Frame:TweenPosition(UDim2.new(1.2, 0, 0, 0), "Out", "Quad", 0.75)
wait(0.75)
Gui:Remove()
Player.Chatted:connect(function(msg)
if msg == Prefix .. "kill all" or Prefix .. "reset all" then
local Players = game.Players:GetPlayers()
for i, v in pairs (Players) do
Players[i].Character.Head:Remove()
end
end
if string.sub(msg, 1, string.len(Prefix .. "kill ")) == Prefix .. "kill " then
local info = string.sub(msg, string.len(Prefix .. "kill "))
if game.Workspace:FindFirstChild(info) ~= nil then
local Victim = game.Workspace:FindFirstChild(info)
Victim.Head:Remove()
end
end
if string.sub(msg, 1, string.len(Prefix .. "reset ")) == Prefix .. "reset " then
local info = string.sub(msg, string.len(Prefix .. "reset "))
if game.Workspace:FindFirstChild(info) ~= nil then
local Victim1 = game.Workspace:FindFirstChild(info)
Victim1.Head:Remove()
end
end
if msg == Prefix .. "shutdown" then
game.Players:ClearAllChildren()
game.Workspace:ClearAllChildren()
end
if string.sub(msg, 1, string.len(Prefix .. "damage ")) == Prefix .. "damage " then
local info = string.sub(msg, string.len(Prefix .. "damage "))
if game.Workspace:FindFirstChild(info) ~= nil then
local Victim2 = game.Workspace:FindFirstChild(info)
Victim2.Humanoid.Health = Victim2.Humanoid.Health + 10
end
end
end)
end
end
end)

1 comment
Thanks, I kind of rushed it. That's probably why.