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

Player Rank TextLable issues?

I've recently asked a question on how to change a TextLable to a players rank in a group. It simply wont work the way I found so I am asking again.

TextLable = Ranking
game.Players.PlayerAdded:connect(function(player)
	Ranking.Text("Rank - " .. player:GetRoleInGroup(0))
end)

Can someone help me? This as basic as I can get.

3 comments

0

You have to put the actual group id, not 0.

0

I know that, I changed it to zero for privacy purposes.

0

There are actually no errors in the output.

2 answers

✓ Accepted answer

I'm confused as to whether you are just trying to set your rank or everyone who joins. If you're just setting your rank then it'd be something like this:

local textLabel = script.Parent:WaitForChild('TextLabel')
local player = game.Players.LocalPlayer
textLabel.Text = player:GetRoleInGroup(919349)

If you're trying to set it for everything, (then you'd need to use ChildAdded as PlayerAdded doesn't work in LocalScripts) - edit. I guess PlayerAdded works in LocalScripts now. It'd be something like this, but with your script so that it doesn't change the same TextLabel, but makes a new one and sets it.


local textLabel = script.Parent:WaitForChild('TextLabel')

local function setText(player)
	textLabel.Text = player:GetRoleInGroup(919349)
end

game.Players.PlayerAdded:connect(function(player)
	setText(player)
end)

-- Will catch your player and everyone whom joined before the script ran. 
for i,v in pairs(game.Players:GetPlayers()) do 
	setText(v)
end

2 comments

0

PlayerAdded works in LocalScripts

0

I took this and what cabbler gave me and took ideas off of them, it works perfect now! Thanks!

  1. If TextLable is exactly equal to ranking then you can use Ranking. 2. PlayerAdded will not fire unless another player joins. Your code is not running. 3. If Ranking is a TextLabel then Text is a property, not a function. That's not correct syntax anyway.
function display(player)
	Ranking.Text = "Rank - " .. player:GetRoleInGroup( ID )
end

game.Players.PlayerAdded:connect(display)

display(game.Players.LocalPlayer)

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