Rank and Username Not Showing

Hello,
Today me and my friend are working on rank titles and usernames. Basically, how this works is there is a username above your character, and right under that is your rank. There are 4 Different ranks. “Owner”, “Builder”, “Tester”, and “Player”. For all of the ranks, except Player, you get a title in the chat as well. (this part works) The rank and username above your head, does not. For me, when I join the game, it displays my username, but the wrong rank. For my friend, and other accounts we have tried, neither the rank or username is shown. We have tried many different things and couldn’t get it to work.

Here’s the script:

local rep = game:GetService("ReplicatedStorage")
local tag = rep.NameTag

game.Players.PlayerAdded:Connect(function(player)

    local char = player.Character or player.CharacterAdded:Wait()

    local head = char.Head

    local hum = char.Humanoid

    local newTag = tag:Clone()
    newTag.Enabled = true
    newTag.Name = player.Name.."Tag"
    newTag.Devposition.Text = "Player"
    newTag.Username.Text = player.Name
    newTag.Parent = head
    newTag.Handler.Disabled = false

    if  char:FindFirstChild("Humanoid").player.Name == "matermoter28" then
        newTag.Devposition.Text = "Owner"
        newTag.Devposition.TextColor3 = Color3.fromRGB(235, 0, 0)
        newTag.Devposition.Owner.Enabled = true
    elseif player.UserId == 268214612 then
        newTag.Devposition.Text = "Builder"
        newTag.Devposition.TextColor3 = Color3.fromRGB(0, 235, 0)
        newTag.Devposition.Builder.Enabled = true
    elseif player.UserId == 679750404 then
        newTag.Devposition.Text = "Helper"
        newTag.Devposition.TextColor3 = Color3.fromRGB(0, 0, 235)
        newTag.Devposition.Builder.Enabled = true
    elseif player.Name == "tkuski08" then
        newTag.Devposition.Text = "Tester"
        newTag.Devposition.TextColor3 = Color3.fromRGB(85, 0, 127)
        newTag.Devposition.Builder.Enabled = true
    end
end)

If anyone could help that would be very helpful.

This is also in a normal script in ServerScriptService.

Humanoid.player?
(Extra words)

    if  char:FindFirstChild("Humanoid").player.Name == "matermoter28" then

Here correct? also sorry if the scripts a bit messy, trying different things

yep.
Why don’t you find the character’s name inside players?

1 Like

You can’t get the player from a humanoid like that.

You need to use GetPlayerFromCharacter to get the player from a character.

Or can’t you just get the character name from the character itself?

2 Likes

How would you write that? my noob self is stuck…

Why are you even trying to get the name of the player from the character?? Could you not just do:

if player.Name == "matermoter28" then

Like what you did here but for yourself here.

Also why do you have a mixture of checking userId and checking username. :laughing: . In general it would be better just to check the userId.

Lol, we tried that a couple times and it didn’t work.

Same for UserID, that somehow didn’t work either

Nevermind, just tried it again and it worked, don’t know what happened, thank you! :joy:

No problem. Just for future reference if you do not already know to get the player from the character you can do something like this:

game.Players.PlayerAdded:Connect(function(plr)

local Char = plr.Character

local PlayerFromChar = game.Players:GetPlayerFromCharacter(Char)

end)

Although I would not recommend this in the context I put above due to you getting the player parameter from the player added event it just shows how to use GetPlayerFromCharacter.

1 Like

Alright, thank you for that. :upside_down_face: