Assigning 'and' or 'or' to variables, applying to 'if' statements

I have been trying this out with group permissions but I can’t seem to get it right. I want to have a group requirement to receive a weapon. You can be in any of the groups, and you will be eligible to get that weapon. I’ve stored the values into a module script. Here’s an example:

-- Module Script

local module = {}

module.Tool1Stats = {
    Groups = Group1 or Group2 or Group3
    RequiredRank = 0

}


-- Main Script

local module  = require(module)

local player = game.Players.LocalPlayer

if player:GetRankInGroup(module.Tool1Stats.Group) > module.Tool1Stats.RequiredRank then
-- give the player tools
end

The problem comes in the if statement. It only checks one of the groups, when I have multiple groups stored, thus if someone isn’t in Group1, but is in group 2 or group 3, they don’t get the weapon even though they should be eligible. How can I solve this?

Call a function which checks all groups in a loop and if theyre in one group it returns true, otherwise false.

Do you understand what does the logical or operator do?
or is a logical operator that returns the left operand if the left operand is truthy, otherwise it returns the right operand.
I presume that Group1 or Group2 or Group3 evaluates to Group1 because of this.

following that logic, does it only return group1 because group1 exists?

for example if I had something like this:

local team  = game.Teams.Black or game.Teams.White or game.Teams.Red or game.Teams.Blue
if Player.Team == team then
-- code
end

It would only check the black team because it exists?

Ok so, in this case the best way to do this would be to use a for loop to iterate through a list of ranks, it would be repetitive to use many logical operators if you only needed to use one.

for example

local Ranks = {1,2,3,4}
 if Ranks[1] > X or Ranks[2] > X or Rank[3] > X or Rank[4] > X then
print("Gets tools")
 end

vs

local Ranks = {1,2,3,4}

    for _, Rank in next, Ranks do
    if Rank > X then
    print("Gets Tools")
    end
    end

Correct

The way you are utilizing or only works when you use nil.

For example:
An inventory script can do this.

local data = DataStore:GetAsync("Player"..Player.UserId) or {} 

If there is no data, it will return nil, so it will move on.

In your case it will always be group one since it is a integer