How do I make a gamepass chat tag?

So, I have a script I’m using that gives a player if they own a VIP gamepass a unique chat tag, and if they own a Mega VIP gamepass they also have another unique chat tag, now if the person has bought both of these gamepasses, I want to make a script so that I have a unique chat tag if you own both of the gamepasses, any ideas how I can make it?

2 Likes
if megavip then
	--Give mega VIP tag.
elseif vip then
	--Give VIP tag.
else
	--Default.
end
3 Likes

Can you explain more please? (I’m sorry I’m a beginner at scripting).

I want to make it so that for example if you have the VIP gamepass the chat tag is (VIP) and if you have the Mega VIP gamepass the chat tag is (Mega VIP) and if you own both gamepasses, it will give a new unique chat tag like (Ultra VIP) or something.

1 Like

You can use ChatService and the SetExtraData() function for it. Now, retrieving ChatService and reaching the SetExtraData() function is a bit of a pain, so I’ll save you the hustle and give you an example code.

-- Variables --

local ServerScriptService = game:GetService("ServerScriptService")
local ChatService = require(ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

-- Variables --

local VIPGamepassId = 1234567890
local MegaVIPGamepassId = 1234567890

-- Scripting --

ChatService.SpeakerAdded:Connect(function(PlayerName)
	local PlayerId = Players[PlayerName].UserId
	local Speaker = ChatService:GetSpeaker(PlayerName)
	
	local OwnsVIPGamepass = MarketplaceService:UserOwnsGamePassAsync(PlayerId, VIPGamepassId)
	local OwnsMegaVIPGamepass = MarketplaceService:UserOwnsGamePassAsync(PlayerId, MegaVIPGamepassId)
	
	if OwnsVIPGamepass and OwnsMegaVIPGamepass then
		Speaker:SetExtraData("Tags", {{TagText = "Ultra VIP", TagColor = Color3.fromRGB(26, 129, 255)}})
	elseif OwnsMegaVIPGamepass then
		Speaker:SetExtraData("Tags", {{TagText = "Mega VIP", TagColor = Color3.fromRGB(97, 255, 49)}})
	elseif OwnsVIPGamepass then
		Speaker:SetExtraData("Tags", {{TagText = "VIP", TagColor = Color3.fromRGB(255, 37, 153)}})
	end
end)

And here is said example code in use:

When owning both Mega VIP and VIP gamepass

image

When owning Mega VIP gamepass

image

When owning VIP gamepass

image

When owning neither gamepasses (so the default user)

image

You can of course expand this however you’d like. This should work for your case, but you should also look at the code and try to understand it. If you care about taking a look at the ChatService documentation (which isn’t very user friendly), here is the link to it:

Hopefully this helped.

3 Likes

FYI: ChatSpeakers have a GetPlayer method, so no need to reinvent the wheel by searching the Players service for the player. This code can also throw in the instance that a non-player speaker is added because they don’t have an associated player instance.

3 Likes

Thank you so so much you are a life saver!