I’m looking for feedback on my code.
ServerScript
local server = require(script.MainModule)
game.Players.PlayerAdded:Connect(function(player)
local settings = {
["General"] = {
Prefix = ":"
},
["Ranks"] = {
Moderators = {},
Administrators = {},
Owners = {},
Creators = {"blvckjakey"},
}
}
spawn(function()
server.run(player, settings)
end)
end)
Module
local admin = {}
admin.run = function(...)
local arguments = {...};
local player = arguments[1]
local settings = arguments[2]
local prefix = settings.General.Prefix
local function isAdmin(target, level)
local rank = string.lower(level)
if rank == "moderator" then
for i,v in pairs(settings.Ranks.Moderators, settings.Ranks.Administrators, settings.Ranks.Owners, settings.Ranks.Creators) do
if target == v then
return true
else
return false
end
end
end
if rank == "admin" then
for i,v in pairs(settings.Ranks.Administrators, settings.Ranks.Owners, settings.Ranks.Creators) do
if target == v then
return true
else
return false
end
end
end
if rank == "owner" then
for i,v in pairs(settings.Ranks.Owners, settings.Ranks.Creators) do
if target == v then
return true
else
return false
end
end
end
if rank == "creator" then
for i,v in pairs(settings.Ranks.Creators) do
if target == v then
return true
else
return false
end
end
end
end
local function findTarget(input)
input = tostring(input):lower()
for _, player in ipairs(game:GetService("Players")) do
if (player.Name:lower():sub(1, #input) == input) then
return player
else
return "Player couldn't be found"
end
end
end
local function adminLog(command, admin, target)
warn(command.." ran the command ".. command .." on ".. target)
end
player.Chatted:Connect(function(message)
local msg = string.lower(message)
if msg:sub(1, 8) == prefix.."respawn" then
if isAdmin(player.Name, "Moderator") then
local subLower = string.lower(msg:sub(9))
if subLower == "me" then
player:LoadCharacter()
else
local target = game.Players:FindFirstChild(msg:sub(9))
if target == nil then
if findTarget(msg:sub(9)) == "Player couldn't be found" then
warn("Player could'nt be found")
else
local tempTarget = findTarget(msg:sub(9))
tempTarget:LoadCharacter()
end
else
target:LoadCharacter()
end
end
else
warn("Player isnt a admin, can't run this command")
end
end
end)
end
return admin