Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Player Rank TextLable issues?

Asked by 7 years ago

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.

0
You have to put the actual group id, not 0. cabbler 1942 — 7y
0
I know that, I changed it to zero for privacy purposes. AdvancedCode 136 — 7y
0
There are actually no errors in the output. AdvancedCode 136 — 7y

2 answers

Log in to vote
-1
Answered by
Azarth 3141 Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

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
0
PlayerAdded works in LocalScripts cabbler 1942 — 7y
0
I took this and what cabbler gave me and took ideas off of them, it works perfect now! Thanks! AdvancedCode 136 — 7y
Ad
Log in to vote
-1
Answered by
cabbler 1942 Moderation Voter
7 years ago
  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)

Answer this question