(SOLVED) How to add Donator tag behind roblox chat username when gamepass is bought

I need help on this becuase i only know how to make it so if the username = blahblahblah then put owner tag behind the username in chat but i dont quite know how to make it so if a gamepass is bought it gives the player a tag behind their user in chat its quite confusing to me

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

local ChatService = ServerScriptService:WaitForChild("ChatServiceRunner").ChatService

local GamepassId = 0
local TagInfo = {
	TagText = "Donator",
	TagColor = Color3.fromRGB(255,255,0)
}

Players.PlayerAdded:Connect(function(Player)
	if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then
		local ChatModule = require(ChatService)
		local Speaker = nil
		repeat
			task.wait(0.05)
			Speaker = ChatService:GetSpeaker(Player.Name)
		until Speaker ~= nil
		Speaker:SetExtraData("Tags", TagInfo)
	end
end)

Use MarketplaceService:UserOwnsGamePassAsync(UserId, GamepassId).

3 Likes