Help with a better way to check and compare a player's groups

I would just like to start off with, I already know how to do what I’m trying to do, however, it will end up with hundreds of lines of if/elseif statements. I thought about putting this in code review, but given the code is not written yet, I think this suits my case.

So here I have a leaderboard, you will notice the “Position” section. What it does is display a player’s main role within a multitude of groups. (The group is a halo group with many military affiliate groups). In the screenshot shown below, the placeholder is “Headhunter” which is equivalent to: Is in group Spartans, Is in group Navy, Is in group ONI but also have a specific role in ONI. I don’t wish to go through a bunch of Are they in X and Y but not Z for each player and each possibility.


(Excuse my bad UI. First time.)

The player card and everything on it is handled in a local script and a server script to make sure every client sees the same things. I was thinking about using module scripts to hold each classification and the required group/roles, but I don’t really know how to properly use module scripts.

All help appreciated

Note: This leaderboard is 100% custom and has nothing to do with the default roblox one.

You could store group IDs and minimum ranks in a dictionary like this.

local groupConfig = {
	[12345678] = 11; -- minimum rank
	[91234567] = 15;
	-- keep going for however many
}

for i,v in pairs(groupConfig) do
	if player:GetRankInGroup(i) >= v then
		-- do something here
	end
end

You could also actually use GroupService if you wanted to have it go into more details about the name of the group or something.

Also, I wanted to point out that your UI isn’t bad for a first time! If you wanted feedback from experienced UI designers you could make a post in this pretty active thread, or alternatively just make a new post altogether in one of the feedback categories.

1 Like

Hey, thanks a lot. Your method is nice but does not really fit my situation. What I’ll probably end up doing is the long a tedious if / elseif statements.