How to restrict menu for certain ranks in group

So, I am wanting to have my debug menu appear only for high ranks in my group.

The issue is that it seems everybody can access it.

I’ve been playing around with tables and GroupService (Both of which I just started to learn today)

What i have now is:

local groupService = game:GetService("GroupService")
local group = 2874380
local rank = {
	255;
	254;
	250;
	240;
	230;
}

-- Function on key press
function keypress (key)
	if player:GetRankInGroup(group) == rank then

I believe the issue to lie in here. I can’t seem to find the solution online so, here i am.

2 Likes

Instead of

player:GetRankInGroup(group) == rank

use

rank[player:GetRankInGroup(group)]

edit: also your table should be like this if you want to use this method

local rank = {
	[255] = true,
	[254] = true,
	[250] = true,
	[240] = true,
	[230] = true
}
2 Likes

To add to his response, you tried to compare a value to a table. Since rank is a table, it cannot be compared to a string or integer, so instead, do what @Minstrix did and check whether the player:GetRankInGroup() is within the table.

2 Likes

You’re unable to add keys which are numbers like this.
Use [key] and it will work.

local rank = {
	[255] = true,
	[254] = true,
	[250] = true,
	[240] = true,
	[230] = true
}
3 Likes

Whoops, I added that to my post. He’ll still need to use the rank[player:GetRankInGroup(group)] though.

1 Like