How would I add a second nametag if a person owns Roblox premium?

It has to like add a second nametag without changing namecolor or chatcolor…

This is my current (messy) script:

local ServerScriptService = game:GetService("ServerScriptService") -- References the "ServerScriptService", which contains certain elements of the chat that are referenced a few lines below

local ChatServiceRunner = ServerScriptService:WaitForChild("ChatServiceRunner") -- References the "ChatServiceRunner", which runs the Chat System on the Server
local ChatService = require(ChatServiceRunner.ChatService) -- References the ChatService, which handles the messages that are sent in the game
local Speakers = ChatService:GetSpeakerList() -- References the list of Speakers in the game, which includes each player and any artificial speakers that are created


local PlayerTags = { -- Creates a table called "PlayerTags", which is where specific players can be added as well as the customized Chat Colors and Chat Tags


	[291507001] = { -- The player with this UserId will have these different chat settings in the game
		ChatColor = BrickColor.new("White").Color, -- Change this to the Color you want the player's messages to appear in
		NameColor = BrickColor.new("Pastel violet").Color, -- Change this to the Color you want the player's name to appear in
		Font = Enum.Font.SourceSansBold, -- Change this to the font you want the text to appear in (if you delete the word "SourceSansBold" and type a letter in, it'll show available Fonts that can be used
		TextSize = 18, -- Change this to the size of the text that the Chat Tag, Player Name, and Messages will be
		Tags = { -- Starts the Tags List (chat tags will be contained in this table)
			{ -- Starts tag 1
				TagText = "Developer", -- Change this to the word(s) that you want in the Chat Tag
				TagColor = BrickColor.new("Alder").Color -- Change this to the Color you want the Chat Tag to appear in
				}, -- Ends tag 1
			}, -- Ends Tags Lista
		}, -- Ends UserId
	[1317936458] = { -- The player with this UserId will have these different chat settings in the game
		ChatColor = BrickColor.new("White").Color, -- Change this to the Color you want the player's messages to appear in
		NameColor = BrickColor.new("Storm blue").Color, -- Change this to the Color you want the player's name to appear in
		Font = Enum.Font.SourceSansBold, -- Change this to the font you want the text to appear in (if you delete the word "SourceSansBold" and type a letter in, it'll show available Fonts that can be used
		TextSize = 18, -- Change this to the size of the text that the Chat Tag, Player Name, and Messages will be
		Tags = { -- Starts the Tags List (chat tags will be contained in this table)
			{ -- Starts tag 1
				TagText = "Moderator", -- Change this to the word(s) that you want in the Chat Tag
				TagColor = BrickColor.new("Bright blue").Color -- Change this to the Color you want the Chat Tag to appear in
				}, -- Ends tag 1
			}, -- Ends Tags Lista
		}, -- Ends UserId
	[379708366] = { -- The player with this UserId will have these different chat settings in the game
		ChatColor = BrickColor.new("White").Color, -- Change this to the Color you want the player's messages to appear in
		NameColor = BrickColor.new("Storm blue").Color, -- Change this to the Color you want the player's name to appear in
		Font = Enum.Font.SourceSansBold, -- Change this to the font you want the text to appear in (if you delete the word "SourceSansBold" and type a letter in, it'll show available Fonts that can be used
		TextSize = 18, -- Change this to the size of the text that the Chat Tag, Player Name, and Messages will be
		Tags = { -- Starts the Tags List (chat tags will be contained in this table)
			{ -- Starts tag 1
				TagText = "Moderator", -- Change this to the word(s) that you want in the Chat Tag
				TagColor = BrickColor.new("Bright blue").Color -- Change this to the Color you want the Chat Tag to appear in
			}, -- Ends tag 1
		}, -- Ends Tags Lista
	}, -- Ends UserId
} -- Ends PlayerTags

local gamepassId = 15177673 -- Gamepass ID
local service = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
	if (service:UserOwnsGamePassAsync(player.UserId, gamepassId)) then
		local tags = {
			{
				TagText = "Premium", -- Tag
				TagColor = Color3.fromRGB(208, 0, 0) -- VIP Color
			}
		}
		local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
		local speaker = nil
		while speaker == nil do
			speaker = ChatService:GetSpeaker(player.Name)
			if speaker ~= nil then break end
			wait(0.01)
		end
		speaker:SetExtraData("Tags",tags)
		speaker:SetExtraData("ChatColor",Color3.fromRGB(255, 255, 255)) -- Text Color
		speaker:SetExtraData("NameColor",Color3.fromRGB(255, 96, 96))		
	end
end)

local function SetChatTags(SpeakerName) -- Creates a function called "SetChatTags" with a parameter of "SpeakerName"
	local speaker = ChatService:GetSpeaker(SpeakerName) -- Defines "speaker" as getting the Speaker from its name
	local player = speaker:GetPlayer() -- Defines "player" as getting the Player from the Speaker 
	
	if player then -- If it is a player, then...
		local PlayerCheck = PlayerTags[player.UserId] -- It will look through the "PlayerTags" table and see if their UserId is listed there
		
		if PlayerCheck then -- If it finds their UserId in the "PlayerTags" table, then...
			for key, value in pairs(PlayerCheck) do -- It will loop through that part of the table, and...
				speaker:SetExtraData(key, value) -- The "key" references the ChatColor, NameColor, Font, TextSize, Tags, etc., and the "value" references what is on the right side of the equals sign
				print("PlayerTag set") -- Print that their PlayerTag has been set to see if it's working
			end -- Ends the PlayerCheck loop
		end -- Ends the "if PlayerCheck" then statement
	end -- Ends the "if player" then statement
end -- Ends the SetChatTags function

ChatService.SpeakerAdded:Connect(SetChatTags) -- Whenever a new Speaker is added into the ChatService (such as a player), it will activate the function called "SetChatTags"
1 Like

Check the API: Player | Roblox Creator Documentation

if plr.MembershipType == Enum.MembershipType.Premium then

end
if player.MembershipType == Enum.MembershipType.Premium then
	--execute code for premium users only
end

Place the above somewhere suitable inside the function you’ve connected to the PlayerAdded event (where player is defined).

I know how to use premium membersships, but how do I ADD a second chattag?