[Solved]How to make group role tag

Hello, i have a script already, it’s working, but one part of it not works, so i wanna ask problem

  1. I wanna make players will have text label above them with their group rank
  2. Last text label with regiment doesn’t appear, here is screenshot:123
  3. I looked in youtube, but i’m new in scripting, so i don’t understood much. Also i took that script from Dev Hub, and made some changes in it.

Here is script:

local commands = {}

function Create(ClassName)
	return function(Properties)
		local Obj = Instance.new(ClassName)
		for i,v in pairs(Properties) do
			if type(i) == 'number' then
				v.Parent = Obj
			else
				Obj[i] = v
			end
		end
		return Obj
	end
end
function HandleCharacter(Player, Character)
	local Custom = Character:WaitForChild('Head'):clone()
	Custom.Name = 'TastiesOverhead'
	Custom.Parent = Character
	Custom.face:Destroy()
	Character.Head.Transparency = 1
	Create'Weld'{
		Name = 'CustomWeld';
		Parent = Custom;
		Part0 = Character.Head;
		Part1 = Custom;
	}
	Create'BillboardGui'{
		Name = 'Nametag';
		Parent = Custom;
		Size = UDim2.new(5, 0, 0.5, 0);
		StudsOffset = Vector3.new(0, 2, 0);
		Create'TextLabel'{
			Name = 'NameLabel';
			BackgroundTransparency = 1;
			Size = UDim2.new(1, 0, 1, 0);
			Position = UDim2.new(0, 0, -0.8, 0);
			Font = 'ArialBold';
			Text = Character.Name;
			TextColor3 = Color3.new(1, 1, 1);
			TextScaled = true;
			TextStrokeTransparency = 1;
		};
		Create'TextLabel'{
			Name = 'RankLabel';
			BackgroundTransparency = 1;
			Size = UDim2.new(1, 0, 0.92, 0);
			Position = UDim2.new(0, 0, 0.2, 0);
			TextTransparency = .1;
			Font = 'SourceSansItalic';
			FontSize = Enum.FontSize.Size14;
			Text = Player:GetRoleInGroup(11357936);
			TextColor3 = Color3.new(1, 1, 1);
			TextScaled = true;
			TextStrokeTransparency = 1;
		};
		--Problem there
		Create'TextLabel'{
			Name = 'CEATTRankLabel';
			BackgroundTransparency = 1;
			Size = UDim2.new(1, 0, 0.92, 0);
			Position = UDim2.new(0, 0, 1.2, 0);
			TextTransparency = .1;
			Font = 'SourceSansItalic';
			FontSize = Enum.FontSize.Size14;
			Text = Player:GetRoleInGroup(11526155);
			TextColor3 = Color3.new(0, 1, 1);
			TextScaled = true;
			TextStrokeTransparency = 1;
		};
		--Problem above
	}

	Custom.BrickColor = Character.Head.BrickColor
	Character.Head.Changed:connect(function()
		Character.Head.Transparency = 1
		Custom.BrickColor = Character.Head.BrickColor
	end)
	Character.Head.Mesh.Changed:connect(function()
		Custom:WaitForChild('Mesh').MeshId = Character.Head:WaitForChild('Mesh').MeshId
	end)
end

local rainbow = function(callback)
	local frequency = 0.1
	local i = 0 
	while true do wait()
		local red = math.sin(frequency*i + 0)*127+128 
		local green = math.sin(frequency*i + 2*math.pi/3)*127+128 
		local blue = math.sin(frequency*i + 4*math.pi/3)*127+128 
		callback(Color3.new(red/255,green/255,blue/255)) i = i+1 
	end end 
function HandlePlayer(Player)
	if Player.Character then
		HandleCharacter(Player, Player.Character)
	end
	Player.CharacterAdded:connect(function(Character) HandleCharacter(Player, Character) end)
	if Player.UserId == 0 or Player.UserId == 0 or Player.UserId == 0 or Player.UserId == 0 then
		Player.CharacterAdded:connect(function(char) local label = char:WaitForChild("TastiesOverhead") 
			coroutine.resume(coroutine.create(rainbow),function(color)label.Nametag.RankLabel.TextColor3 = Color3.new(color.r,color.g,color.b)end) 
		end)
	end
end
game.Players.PlayerAdded:connect(function(b)
	HandlePlayer(b)
end)
for i,v in pairs(game.Players:GetPlayers()) do
	HandlePlayer(v) 
end

I have no idea what problem is

2 Likes

thats what

player:GetRankInGroup(group id)

is for .
i hope this helped!

That script is a mess not going to lie, there is easier ways of getting a player’s rank and their tag just by cloning it from replicated storage or something like it. For example;

Nametag.Rank.Text = Player:GetRoleInGroup(1)

That’d just set their rank text of the nametag to their rank in the group, 1 for example, or ROBLOX’s main group.
I’d recommend watching SheaNorse’s nametag tutorial, as it’s a lot more simple and easier to understand in my opinion.

1 Like

Thanks, lemme watch this video

And also this will write rank not role, so it will be look like that : 255 212

:GetRankInGroup() is an integer value between 0 meaning their not in the group to 255 meaning the groups owner.

GetRoleInGroup() is a string value in which is the name of the role/rank.

Inside the parentheses should contain the groupId number.

I believe you need to use a single line of code to get the player’s group role name, player:GetRoleInGroup(GroupId) will do it all

Example:

local GroupId = 1234567
local Player = game.Players.LocalPlayer

print(Player:GetRoleInGroup(GroupId))

-- prints out "Member" if the player has the role named "Member" in the group, if player isn't in the group then it will print out "Guest" instead

You guys again a problem, can’t get Player name without a reason, no idea why, script :

local SS = game:GetService("ServerStorage")
local nametag = SS.RankLabel
local text = nametag.Text
local RankText = nametag.RankText
game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(char)
		local Head = char.Head
		text.Text = game.Players.LocalPlayer.Name
		local newtext = nametag:Clone()
		
		newtext.Parent = Head
		newtext.Adornee = Head
			text.Text = game.Players.LocalPlayer.Name
	end)
end)

Oh wait fixed already, sorry.
Thank you all guys

Thanks everyone i solved problem