Hey there so I’m making an admin command system and wrote a function that would return if a player is allowed to use a command.
if commands[command] then
local rankNeeded = commands[command][1]
if rankNeeded < plr:GetRankInGroup(GroupID) or (rankNeeded == Officer and plr:GetRankInGroup(GroupID) == SM) then
return true
else
return false
end
else
MainModule.invalid('function not found')
end
end
For the past few days, this worked perfectly and I didn’t change any of the code but it throws the error
attempt to index nil with ‘GetRankInGroup’ and I’m pretty sure I defined the player variably correctly.
Command function below
MainModule.bring = function (plr, args, plr2)
print('Bring ')
print(args)
local character = plr.Character
local plr2Name
if args[2] ~= nil then
plr2Name = (args[2])
else
plr2Name = ''
end
if returnRank(plr, 'bring') then
if getTarget(plr2Name, plr) then
print('target found')
local target = getTarget(plr2Name)
local targetChar = target.Character or target.CharacterAdded:Wait()
local mainChar = plr.Character or plr.CharacterAdded:Wait()
if CompareRank(target, plr) then
targetChar.HumanoidRootPart.CFrame = targetChar.HumanoidRootPart.CFrame + (mainChar.HumanoidRootPart.CFrame.LookVector * mainChar.HumanoidRootPart.Position)
MainModule.logcommand(plr, 'bring')
end
end
end
end
Server script below (this will fire the functions)
local setting = require(script.Parent.Parent.Modules.Settings)
local prefix = setting.Prefix
local commands = require(script.Parent.Parent.Modules.Commands)
local Main = require(script.Parent.Parent)
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
Main.PlrAdded()
msg = string.lower(msg)
local splitstring = msg:split(' ')
local slashCommand = splitstring[1]
local cmd = slashCommand:split(prefix)
local cmdName = cmd[2]
print(cmd[2])
Main[cmdName](plr, splitstring, nil)
if commands[cmdName] then
Main[cmdName](plr, cmd, nil)
end
end)
end)
Help will be appreciated thank you.