A question on how to check if a player is in a certain group of ranks

So for checking a players group rank can I make it to were it checks if its a group of ranks, for example if players are in Rank ID 2 and Rank ID 5 how would i write it out in a script, ik you can only check for ranks higher and lower but never in a range of ranks.

game.Players.PlayerAdded:Connect(function(plr)
   if plr:GetRankInGroup(groupId) == 1 then
-- do something here
end
end)

and you can also do this

game.Players.PlayerAdded:Connect(function(plr)
   
   if plr:GetRankInGroup(groupId) >= 1 or == 1 then
-- do something
end
end)

so how can you script it out if you want it greater then a number but not higher then a another number

like in algebra you can write it out like this 1<y<4, it might be wrong on how i wrote it but it practically means it can be through 1-4, here is a visual since i’m bad a explaining:


think of those numbers as my group ID’s but instead of having the line going through all real numbers greater than two, or just plotting a number at two, i want it in a specific range. Like shown above, so let me write it out again:

game.Players.PlayerAdded:Connect(function(plr)
   
   if plr:GetRankInGroup(groupId) --the inequality here, 2<x<5, how would i write it out in code?
-- do something
end
end)

This might be confusing to some people, so in a easy explanation: How would I check if a player is ranked in a certain group of ranks ex: checking if they are in rank 2 through 5, if they perhaps are in those ranks they get something in-game

1 Like
if plr:GetRankInGroup(groupId) >= 2 and plr:GetRankInGroup(groupId) <=5 then
    --do something
end
1 Like

Oh wow, didn’t think of it like that, thought it would be more complicated, thanks for the help!

1 Like

No problem, glad I could help.

Wait… I made an oops in it… does it work? If it doesn’t copy and paste the code and try again.

1 Like