GUI that displays the player's rank in a group

I have a join screen GUI in a game I am making, within that join screen GUI I have a GUI that displays the player’s rank in a group. However I have ran into a lot of difficulties with this. Put simply the script just isn’t changing the GUI’s text.

I tried to fix it via looking for other ways to refer to the player and testing each time on localscripts and scripts but no method seemed to work.

local plr = game.Players.LocalPlayer
if plr:GetRankInGroup(2831912) == 255 then
	script.Parent.Text = "The Imperium"
elseif plr:GetRankInGroup(2831912) == 20 then
	script.Parent.Text = "O5-1"
elseif plr:GetRankInGroup(2831912) == 19 then
	script.Parent.Text = "O5"
elseif plr:GetRankInGroup(2831912) == 18 then
	script.Parent.Text = "Developer"
elseif plr:GetRankInGroup(2831912) == 16 then
	script.Parent.Text = "Board of Directors"
elseif plr:GetRankInGroup(2831912) == 15 then
	script.Parent.Text = "Assistant Director"
elseif plr:GetRankInGroup(2831912) == 13 then
	script.Parent.Text = "SCP"
elseif plr:GetRankInGroup(2831912) == 12 then
	script.Parent.Text = "Close Associates"
elseif plr:GetRankInGroup(2831912) == 11 then
	script.Parent.Text = "Class A"
elseif plr:GetRankInGroup(2831912) == 9 then
	script.Parent.Text = "Level V"
elseif plr:GetRankInGroup(2831912) == 8 then
	script.Parent.Text = "Level IV"
elseif plr:GetRankInGroup(2831912) == 7 then
	script.Parent.Text = "Level III"
elseif plr:GetRankInGroup(2831912) == 6 then
	script.Parent.Text = "Level II"
elseif plr:GetRankInGroup(2831912) == 5 then
	script.Parent.Text = "Level I"
elseif plr:GetRankInGroup(2831912) == 4 then
	script.Parent.Text = "Facility Clearance"
elseif plr:GetRankInGroup(2831912) == 2 then
	script.Parent.Text = "Exiled"
elseif plr:GetRankInGroup(2831912) == 1 then
	script.Parent.Text = "Class Disposable"
end

Where is this script located? A picture of the explorer would help.

Also instead of using a bunch of elseif statements, just use a dictionary like this:

--//Services
local Players = game:GetService("Players")

--//Variables
local LocalPlayer = Players.LocalPlayer
local TextLabel = script.Parent

--//Controls
local groupId = 2831912

--//Tables
local rankNames = {
	[255] = "The Imperium",
	[20] = "O5-1",
	[19] = "O5",
	[18] = "Developer",
	[16] = "Board of Directors",
	[15] = "Assistant Director",
	[13] = "SCP",
	[12] = "Close Associates",
	[11] = "Class A",
	[9] = "Level V",
	[8] = "Level IV",
	[7] = "Level III",
	[6] = "Level II",
	[5] = "Level I",
	[4] = "Facility Clearance",
	[2] = "Exiled",
	[1] = "Class Disposable",
	[0] = "Class Disposable",
}

--//Functions
TextLabel.Text = rankNames[LocalPlayer:GetRankInGroup(groupId)]
2 Likes

image

Try this code:

--//Services
local Players = game:GetService("Players")

--//Variables
local LocalPlayer = Players.LocalPlayer
local TextLabel = script.Parent

--//Controls
local groupId = 2831912

--//Tables
local rankNames = {
	[255] = "The Imperium",
	[20] = "O5-1",
	[19] = "O5",
	[18] = "Developer",
	[16] = "Board of Directors",
	[15] = "Assistant Director",
	[13] = "SCP",
	[12] = "Close Associates",
	[11] = "Class A",
	[9] = "Level V",
	[8] = "Level IV",
	[7] = "Level III",
	[6] = "Level II",
	[5] = "Level I",
	[4] = "Facility Clearance",
	[2] = "Exiled",
	[1] = "Class Disposable",
	[0] = "Class Disposable",
}

--//Functions
TextLabel.Text = rankNames[LocalPlayer:GetRankInGroup(groupId)]

Tell me about any errors.

Also, can you zoom out a bit? The picture doesn’t include the service its in, which is vital for figuring out the problem.

1 Like

It is very much fixed thank you for your help!!

1 Like

No problem. If you have any more questions, feel free to ask.

1 Like

Thank you so much for your help, I hope you have a good day!!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.