Help with nametags

So I am currently trying to add on to a script that I’m working on so if a player has a gamepass (that comes with a nametag) and is a developer, they would get a nametag for said things and it’d slowly switch between the two, but I’m not quite sure on how to do it.

More details are in the code attached and the pictures attached.


Snippet of the code, with explanation.
if Player.Name == "Name" or Player.Name == "Name" or Player.Name == "Name" then -- Name is just a placement for the Player's name.
		tagtext = "[DEVELOPER]" -- The tag that they get, that'll be above their username.
		tag.TextColor3 = Color3.fromRGB(255, 255, 255) -- The colour of the tag, obviously.
	elseif game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, 10906559) then -- This one is for a gamepass, if they own it they get the tag!
		tagtext = "[PREMIUM]" -- The tag that they get, that'll be above their username. (again.)
		tag.TextColor3 = Color3.fromRGB(146, 166, 255) -- The colour of the tag. (again)
	
-- It ends then other parts of the script gets added.
Pictures

Screenshot_2

Screenshot_3


If you really need the full code, DM me and I’ll send it to you.

What do you mean by slowly switch between the two?

I mean it’d stay on one tag for some time then switch to the other tag.

Use a while True do loop to repeatedly switch between the 2. Then do wait(time in seconds) to delay the switch.

So here is some pseudo code for this

if player is developer and player owns game pass then
While loop
tagtext = “[DEVELOPER]” – The tag that they get, that’ll be above their username.
tag.TextColor3 = Color3.fromRGB(255, 255, 255) – The colour of the tag, obviously.
wait seconds
tagtext = “[DEVELOPER]” – The tag that they get, that’ll be above their username.
tag.TextColor3 = Color3.fromRGB(255, 255, 255) – The colour of the tag, obviously.

if Player.Name == "Name" or Player.Name == "Name" or Player.Name == "Name" and game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, 10906559) then
while True do
tagtext = "[DEVELOPER]" -- The tag that they get, that'll be above their username.
		tag.TextColor3 = Color3.fromRGB(255, 255, 255) -- The colour of the tag, obviously.
wait(5)
tagtext = "[PREMIUM]" -- The tag that they get, that'll be above their username. (again.)
		tag.TextColor3 = Color3.fromRGB(146, 166, 255) -- The colour of the tag. (again)
wait(5)
end
end

@Niqhtlyy

You could probably do this by comparing both of your if statements together, and putting your code through a loop like the above post stated, although you might need to detect when you want to break the loop:

local MarketService = game:GetService("MarketplaceService")
local DevNames = {
    "Owner";
    "Developer";
    "OtherDeveloper";
}

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")

        if table.find(DevNames, Player.Name) and MarketService:UserOwnsGamePassAsync(Player.UserId, 10906559) then

            while true do
                tagtext = "[DEVELOPER]"
                tag.TextColor3 = Color3.fromRGB(255, 255, 255)
                wait(3) 
                tagtext = "[PREMIUM]"
                tag.TextColor3 = Color3.fromRGB(146, 166, 255)
                wait(3)
                if Humanoid.Health == 0 then
                   break
                end
            end

        end
    end)
end)
1 Like

Maybe, but the code can work way more organized & optimized that way (Just my personal preference)

Ok. Fair enough. Your code does seem a lot more organized than mine, I’m on mobile right now so my code isn’t really, the best shall we say.

You can also do
for i, v in pairs(player) do
to loop through the players instead of
table.find()

I just find it easier to do table.find, mainly due to its simplistic nature

If the table can’t find anything, it’d just result in a nil value

1 Like

I tried that the whole tag just disappeared, I did try my own methods after but it just gave me the “Developer” tag even though I own the gamepass for the “Premium” tag.

The WHOLE tag disappeared? Then you may need to send a topic on #bug-reports.

No, the tag disappeared because of the code I put in. Plus, I can’t send bug reports due to not being a Regular.

Changing text won’t remove the tag. It just changes the text. You may want to try what @JackscarIitt recommended.

I came up with something like this. Whitelist table holds the player name’s that are developers. Tags table is sort of extra, but I added it so you don’t repeat the color and text parts. UserOwnsGamePassAsync returns a bool indicating if the player owns the pass, so I made that portion a variable so I can easily check if they own the pass when needed.

local MarketplaceService = game:GetService("MarketplaceService")

local Whitelist = {
	"Name",
	"Name",
	"Name"
}

local Tags = {
	Developer = {
		Text = "[DEVELOPER]",
		Color = Color3.fromRGB(255, 255, 255)
	},
	Premium = {
		Text = "[PREMIUM]",
		Color = Color3.fromRGB(146, 166, 255)
	}
}

local Whitelisted = table.find(Whitelist, Player.Name)
local OwnsPass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, 10906559)
	
if Whitelisted then
	if OwnsPass then
		while true do
			tagtext = Tags.Developer.Text
			tag.TextColor3 = Tags.Developer.Color
				
			wait(3)
				
			tagtext = Tags.Premium.Text
			tag.TextColor3 = Tags.Premium.Color
				
			wait(3)
		end
	else
		tagtext = Tags.Developer.Text
		tag.TextColor3 = Tags.Developer.Color
	end
elseif OwnsPass then
	tagtext = Tags.Premium.Text
	tag.TextColor3 = Tags.Premium.Color
end

I’m not sure how you’re defining player and stuff so you need to put this where it best fits if you decide to use it.

No worries, I’ve done it myself and it works!