Help with my nametag script

Good evening, I was hoping that somebody could help me. (I’m new to this forum thingy so I may accidentally post this somewhere I’m not meant to)

Now, what I am trying to make it say is:
Username | ALPHA-1 “RED RIGHT HAND”
Rank In Group Below

Usually it’s only
Username
Rank In Group Below

I am not really sure what I am doing wrong (I’m not really much of a scripter, but some guidance would be nice. As you can see in the “Special Operations” script area I am testing it out. Currently the nametag for the team I want it to the newish nametag is just completely blank, no nametag there for that team. Please help, thanks.

I can try to provide more information if needed.

2 Likes

You’re gonna have to re-script it all im pretty sure.

The problem with your code is that you did not seem to concatenate properly, normally you would do this:

local var = "pretty true"
print("blah blah but " .. var)

Another thing is your use of elseifs, you can swap that with a dictionary to avoid repetition:

local ranks = {
	["Intelligence Agency"] = {
		User = "",
		Rank = "???" --don't know what this is supposed to be
	},

	["Social Operations"] = {
		User = "%s | ALPHA-1", --%s is the display name, look at string.format() documentation for more information
		Rank = "???" --don't know what this is supposed to be
	}
}


--Now instead of that elseif nightmare you can just do

local rankInfo = ranks[Player.Team.Name] or {}

RankTag.User.Text = string.format(rankInfo.User or "defaultUserText", Player.DisplayName)
RankTag.Rank.Text = rankInfo.Rank or "defaultRankText"

Of course, you’re gonna have to properly implement this into your code.

Thank you! I’ll take a look as soon as I can.