Help with admin commands

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Fully Functional admin commands

  2. What is the issue? Include screenshots / videos if possible!
    The module script containing the commands work but the code within the module functions do not.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have searched the devforum but none worked for me

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Commands (script in serverscriptservice)

local commands = require(game:GetService("ServerScriptService"):WaitForChild("AdminCommands"))
local admins = require(game:GetService("ServerScriptService"):WaitForChild("Admins"))

local prefix = "/"

game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if table.find(admins, player.UserId) then
local message = msg:lower()
local split = message:split(" ")
local command = split[1]:split(prefix)
if commands[command[2]] then
local arguments = split
table.remove(arguments, 1)
if #arguments > 0 then
commands[command[2]](player, table.unpack(arguments)) end
end
end
end)
end)

Admins (modulescript in serverscriptservice)

local admins = {
1220039795;
}

return admins

AdminCommands (module script in serverscriptservice)

local commands = {}

commands.kill = function(admin, arguments)
print("Kill command has been run by:", admin.Name)
local target = arguments[1]
if target == "me" then
admin.Character.Humanoid.Health = 0
elseif target == "others" then
for _, v in pairs(game.Players:GetPlayers()) do
if v.Name ~= admin.Name then
v.Character.Humanoid.Health = 0
end
end
elseif target == "all" then
for _, v in pairs(game.Players:GetPlayers()) do
v.Character.Humanoid.Health = 0
end
elseif target == "admins" then
for _, v in pairs(game.Players:GetPlayers()) do
local admins = require(game:GetService("ServerScriptService"):WaitForChild("Admins"))
if table.find(admins, v.UserId) then
v.Character.Humanoid.Health = 0
end
end
else
for _, player in pairs(game.Players:GetPlayers()) do
local newtarget = player.Name:lower()
if newtarget == target then
player.Character.Humanoid.Health = 0
end
end
end
end

return commands

the kill command fires properly, but the code within it doesn’t work
there arent any errors in the console

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

I found the error, table.unpack() returns the values within it, deleting the table and the function separates the arguments

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.