Help with overhead GUI

Hi, I’m scripting an overhead rank GUI for my group game but my problem is with the GetRankInGroup. I have no errors in the output but it keeps giving people the same rank (Grandmaster of the Order). Any help? I’m trying to make it so it shows their rank in the group.

Image of problem:


[Person on the right should have “Force Sensitive”

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

--// Variables //--

local ServerStorage = game:GetService("ServerStorage")
local BillboardGui = ServerStorage:WaitForChild("BillboardGui")

--// Code //--

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		
		local tag = BillboardGui:Clone()
		tag.Parent = character.Head
		
		--// Groups //--
		
		local JediGroup = 5809884
		local GuardianGroup = 5860534
		local ConsularGroup = 5809928
		local SentinelGroup = 5860245
		
		--// NameTag //--
		
		local NameTag = tag.NameTag
		
		NameTag.Text = player.Name
			
		--// RankTag //--
						
		local RankTag = tag.RankTag
						
		if player:GetRankInGroup(5809884) == 255 then
			RankTag.Text = "Grandmaster of the Order"
							
		elseif player:GetRankInGroup(5809884) == 254 then
			RankTag.Text = "Master of the Order"
							
		elseif player:GetRankInGroup(5809884) == 253 then
			RankTag.Text = "Jedi Architect"
							
		elseif player:GetRankInGroup(5809884) == 252 then
			RankTag.Text = "Jedi High Council"
							
		elseif player:GetRankInGroup(5809884) == 251 then
			RankTag.Text = "Force Ghost"
							
		elseif player:GetRankInGroup(5809884) == 250 then
			RankTag.Text = "Jedi Master"
							
		elseif player:GetRankInGroup(5809884) == 249 then
			RankTag.Text = "Jedi Sentintel"
							
		elseif player:GetRankInGroup(5809884) == 248 then
			RankTag.Text = "Jedi Consular"
							
		elseif player:GetRankInGroup(5809884) == 247 then
			RankTag.Text = "Jedi Guardian"
							
		elseif player:GetRankInGroup(5809884) == 246 then
			RankTag.Text = "Jedi Knight"
							
		elseif player:GetRankInGroup(5809884) == 245 then
			RankTag.Text = "Padawan"
							
		elseif player:GetRankInGroup(5809884) == 244 then
			RankTag.Text = "Initiate"
							
		elseif player:GetRankInGroup(5809884) == 243 then
			RankTag.Text = "Youngling III"
							
		elseif player:GetRankInGroup(5809884) == 242 then
			RankTag.Text = "Youngling II"
							
		elseif player:GetRankInGroup(5809884) == 241 then
			RankTag.Text = "Youngling I"
							
		elseif player:GetRankInGroup(5809884) == 240 then
			RankTag.Text = "Force Sensitive"
		
		end		
	end)
end)

This is very similar to your problem. ^

If not, i’ll leave a detailed reply if neccessary.

Yeah sorry, i think need an explanation

Essentially your if statement is fetching the first result instead of continuing downwards, this could be due to multiple reasons but mainly based on how IF and ELSEIF work within Roblox. A few solutions I am aware of would be changing the ELSEIF’s to ends and adding an end between each statement such as

IF <- Script stopping here

ELSEIF

ETC..

Solution (attempt?) #1

if player:GetRankInGroup(5809884) == 255 then
	RankTag.Text = "Grandmaster of the Order"
end				
if player:GetRankInGroup(5809884) == 254 then
	RankTag.Text = "Master of the Order"
end

Another solution would be adding an end at the first if and removing one from the bottom to close out the first if like suggested in the previous document I sent:

if player:GetRankInGroup(5809884) == 255 then
	RankTag.Text = "Grandmaster of the Order"
end		
elseif player:GetRankInGroup(5809884) == 254 then
	RankTag.Text = "Master of the Order"

Try a few things out, let me know how it goes.

Well assuming you’re just using the names of group roles you have and not changing any of their titles in-game, something like this would be much more efficient rather than going through all of them individually.

RankTag.Text = player:GetRoleInGroup(5809884)

Deleted the first post because I used my own group ID to test and didn’t want you to get confused (lol)
Anyways I agree with the post above on how your script should be done so here’s the rewritten version in entirety and I have tested it.

--// Variables //--
	local ServerStorage = game:GetService("ServerStorage")
	local BillboardGui = ServerStorage:WaitForChild("BillboardGui")

--// Code //--

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)

		local tag = BillboardGui:Clone()
		tag.Parent = character.Head

		--// Groups //--

			local JediGroup = 5809884
			local GuardianGroup = 5860534
			local ConsularGroup = 5809928
			local SentinelGroup = 5860245

			--// NameTag //--

			local NameTag = tag.NameTag

			NameTag.Text = player.Name

			--// RankTag //--

			local RankTag = tag.RankTag
			RankTag.Text = player:GetRoleInGroup(JediGroup)
		end)
	end)