Missing argument #2

  1. What do you want to achieve? Keep it simple and clear!
    I want to check if the player who sends the message, is in the group and has a specific rank.

  2. What is the issue? Include screenshots / videos if possible!
    I keep getting an error.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried, but I couldn’t find any.

local FullUse = {255, 111, 11, 12, 14}
local OnlyMute = {9}
local MuteAndKick = {10}

local Commands = {"mute", "general_ban", "server_ban", "announcement"}

Players.PlayerAdded:Connect(function(Player)
    Player.Chatted:Connect(function(Message,Recipient)
            -- Full Use
        if Player:IsInGroup(GroupId) and Player:GetRankInGroup(GroupId) == table.find(FullUse) then
            if string.lower(Message) == "I AM PRO" then
                print(Player.Name.." said that he is pro")
            end
        end
    end)
end)

Error:
image

Line 15: if Player:IsInGroup(GroupId) and Player:GetRankInGroup(GroupId) == table.find(FullUse) then

table.find() needs a second argument, the value you’re trying to find.

You’re using table.find wrong, you have to give it a table and an element to find in table, so change

Player:GetRankInGroup(GroupId) == table.find(FullUse)

To

table.find(FullUse, Player:GetRankInGroup(GroupId))

Also in this case you do not need to use IsInGroup, since if you’re not in a group GetRankIngroup returns 0

And some advice, I recommend checking the GetRankIngroup before you make the Chatted event, so that way only those that are able to do commands will be listened for chat messages, saves having useless events unlses you plan to make general commands that anyone can use

local Players = game:GetService("Players")

local Prefix = "!"
local GroupId = 10415026

local FullUse = {255, 111, 11, 12, 14}
local OnlyMute = {9}
local MuteAndKick = {10}

local Commands = {"mute", "general_ban", "server_ban", "announcement"}

Players.PlayerAdded:Connect(function(Player)
    Player.Chatted:Connect(function(Message,Recipient)
            -- Full Use
        if Player:IsInGroup(GroupId) and table.find(FullUse, Player:GetRankInGroup(GroupId)) then
            if string.lower(Message) == "I AM PRO" then
                print(Player.Name.." said that he is pro")
            end
        end
    end)
end)


``` It didn't show any error but it didn't print.

You’re trying to compare a lower case message with an upper case message, instead of string.lower, use string.upper or lowercase your string

if string.lower(Message) == "i am pro" then
-- stuff
end

Oh yeah, I forgot abt that. Thanks.

1 Like