Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to display a group rank in a text label?

I have a group and I want a billboard GUI to edit a text label inside the billboard GUI to show their rank in the group. However, I can't find anything on how to get their rank in the group. I also want it so if they are not in the group, says ' Guest '. I get stuck on line 7

https://gyazo.com/9bd2b87e8e55b6cc36704e9d027602cf

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

game.Players.PlayerAdded:Connect(function(player)
	
	player.CharacterAdded:Connect(function(character)
		
		if player:GetRankInGroup then
			local clonedgui = billboardgui:Clone()
			clonedgui.Name.Text = player.Name
			clonedgui.TextLabel.TextColor3 = Color3.fromRGB(223, 255, 11)
			clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head
		
		end
		
		
	end)
	
	
end)

1 answer

✓ Accepted answer

#Introduction Hello friend! I see you have an issue regarding a TextLabel issue.

I already spotted multiple errors off-the-bat, and I highly suggest you turn on the output tab. If you don't know where that is, go to studio's top bar > View > Output.

#Answer/Solution

In the introduction, I mentioned that I spotted some errors. Here are the errors I found:

On line 1, you don't need to use :GetService. That is only used in special occasions that I don't even know.

On line 7, you did:

if player:GetRankInGroup then
	--code
end

However, that is incorrect! You simply forgot the brackets that tell that certain function what the group you want to get the rank from.

So here would be the fixed version:

if player:GetRankInGroup('groupID') == groupRankID then --change the groupID to your group ID, change the groupRankID to the rank number of the group.
	--code
end

Then, on line 9, you set the TextLabel's text to be the player's name, so here would be the fixed version:

if player:GetRankInGroup(12345678910) == 123 then
	local billboardGuiClone = billboardgui:Clone()
	billboardGuiClone.TextLabel.Text = player:GetRankInGroup(12345678910)
end

Lastly, on line 11, I would suggest parenting it using your character you defined in the .CharacterAdded function.

billboardGuiClone.Parent = character:WaitForChild('Head')

#Conclusion

Man, that was a lot of words!

I really hope this helped, happy scripting! :D

This discussion is preserved as it was. New answers, comments, and votes are closed.