I am making a game and im trying to make a custom admin instead of using hd admin or something but I need a kick player and a ban player commands but I don’t know where to start and have no idea on how to do either of those here is my admin script:
local commands = {}
local prefix = "/"
local admins = {
"PuffyJasonrocks84";
"1BATGIRLL"
}
local function findplayer(name)
for i, player in pairs(game.Players:GetPlayers()) do
if string.lower(player.Name) == name then
return player
end
end
return nil
end
local function isAdmin(player)
for _, v in pairs(admins) do
if v == player.Name then
return true
end
end
return false
end
commands.tp = function(sender, arguments)
print("TP Function Fired by"..sender.Name)
for i, playerName in pairs(arguments) do
print(playerName)
end
local playerToTeleportName = arguments[1]
local playerToTeleportToName = arguments[2]
if playerToTeleportName and playerToTeleportToName then
local plrToTp = findplayer(playerToTeleportName)
local plrToTPTo = findplayer(playerToTeleportToName)
if plrToTp and plrToTPTo then
plrToTp.Character.HumanoidRootPart.CFrame = plrToTPTo.Character.HumanoidRootPart.CFrame
print("Successfully Moved!")
end
end
end
commands.BanPlayer = function(sender, arguments) -- I want this function to be my ban command code
print("Ban Command Fired By "..sender.Name)
end
game.Players.PlayerAdded:Connect(function(dude, sender, arguments)
dude.Chatted:Connect(function(String)
if string.find(String, "/message") then
local Message = string.split(String, "/message")
local M = Instance.new("Message")
M.Text = dude.Name .." Said: ".. Message[2]
M.Parent = game.Workspace
task.wait(5)
M.Parent = nil
end
end)
end)
commands.speed = function(sender, arguments)
print("Speed Command Fired By"..sender.Name)
local playerToGiveSpeedTo = arguments[1]
local amountofspeedtogive = arguments[2]
if playerToGiveSpeedTo then
local plr = findplayer(playerToGiveSpeedTo)
if plr then
plr.Character.Humanoid.WalkSpeed = tonumber(amountofspeedtogive)
print(playerToGiveSpeedTo.." was given WalkSpeed "..amountofspeedtogive)
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message,recipient)
if isAdmin(player) then
message = string.lower(message)
local spitString = message:split(" ")
local slashCommand = spitString[1]
local cmd = slashCommand:split(prefix)
local cmdName = cmd[2]
if commands[cmdName] then
local arguments = {}
for i = 2, #spitString, 1 do
table.insert(arguments,spitString[i])
end
commands[cmdName] (player,arguments)
end
end
end)
end)
Thanks.