I am making an admin commands script and it works. I then added in a check to make sure that the player is an admin and whenever I fire the func to check it, it returns an error:
10:42:22.132 - ServerScriptService.AdminCmds:16: attempt to index nil with 'Name'
Is Admin Func:
local function isAdmin(player) --Checking if the requested player is an admin--
print(player.Name)
for _, v in pairs(admins) do --Getting the "admins" table at line 3 and looping through it--
print(v)
if v == player.Name then --If the player's name is an Admin--
return true
end
end
return false
end
Player Chatted Func:
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message,recipient)
message = string.lower(message)
local splitString = message:split(" ") --Splitting up the message the player sent to see if they were typing a command or not--
local commandPrefix = splitString[1] --Getting the command from the message the player typed--
local cmd = commandPrefix:split(prefix) --Getting rid of the prefix--
local cmdName = cmd[2] --If the player typed an actual command--
if commands[cmdName] then --Checking if the command is an actual command--
local arguements = {} --All of the things the player typed--
if isAdmin(player) then
for i = 2, #splitString, 1 do
table.insert(arguements,splitString[i])
end
commands[cmdName](player,arguements) --Fire command function--
else
print("Not an Admin")
end
end
end)
end)
Thanks for the help! If you would like to see the full script, let me know (there is over 200 lines).

3 comments
Hello, Brody, can you give me lines 0-16 in the script "AdminCmds?"
local function isAdmin(player) --Checking if the requested player is an admin-- print(player.Name) for _, v in pairs(admins) do --Getting the "admins" table at line 3 and looping through it-- print(v) if v == player.Name then --If the player's name is an Admin-- return true end end return false end
Those are lines 15 - 24. The other lines are variables and another func (it works)