Player Text Chat Title Not Working

I have searched the deep depths of the Dev Forum for ways to implement a system where when a player owns a game pass and in which sends a message that a VIP chat title will be next to there name, using roblox’s new TextChatService thing not the Legacy one. Here is what i’ve come up with and it doesn’t seem to work, no errors are in my output.

The server script is needed to make sure the player owns the gamepass.
The local script is in StarterPlayerScripts.

Local Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TextChatService = game:GetService("TextChatService")
local Player = game.Players.LocalPlayer


ReplicatedStorage.GamePassCheck.OnClientEvent:Connect(function(hasGamePass)
	
	local function onMessageReceived(message, player)
		-- If the player has the VIP game pass, prepend the VIP tag
		if player == Player and hasGamePass then
			local VIPTag = "[VIP] "
			local VIPColoredTag = "<font color='#FFFF00'>"..VIPTag.."</font>"
			message = VIPColoredTag .. message
		end
		return message
	end

	
	TextChatService.OnIncomingMessage = function(message, player)
		message = onMessageReceived(message, player)
		return message
	end
end)

ServerScript

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

local GamePassID = 1037931858 

-- Create RemoteEvent for Game Pass check if it doesn't exist
if not ReplicatedStorage:FindFirstChild("GamePassCheck") then
	local remote = Instance.new("RemoteEvent")
	remote.Name = "GamePassCheck"
	remote.Parent = ReplicatedStorage
end

game.Players.PlayerAdded:Connect(function(Player)
	local hasGamePass = false
	local success, result = pcall(function()
		hasGamePass = MarketplaceService:UserHasGamePassAsync(Player.UserId, GamePassID)
	end)

	-- Fire event to client with result of game pass check
	if success then
		ReplicatedStorage.GamePassCheck:FireClient(Player, hasGamePass)
	end
end)

GOAL:
Screenshot 2025-01-21 055411

Hello, I watched a video about this exact topic not too long ago and it seems to be exactly what you’re looking for.
https://www.youtube.com/watch?v=0pyovYhScX8
Hope it helps!

The only issue with the video is it seems as if the gamepass check is also done in the local script. Make sure to do the gamepass check in a server script just like you did in your code.

Your .OnIncomingMessage callback function must return a TextChatMessageProperties object, and not the message itself

On that TextChatMessageProperties, you need to set .PrefixText to your tags (I’m not sure if the player name is included in that)

MarketplaceService’s UserOwnsGamePassAsync method works when used in a LocalScript, so all you need to do to add a chat title is:

-- LocalScript in StarterPlayerScripts
local MarketplaceService = game:GetService("MarketplaceService")
local TextChatService = game:GetService("TextChatService")

local GAMEPASS_ID = 1037931858
local VIP_TAG = "<font color='#FFFF00'>[VIP] </font>"


local function userOwnsGamePass(userId: number, gamepassId: number): boolean
	local success, result = pcall(MarketplaceService.UserOwnsGamePassAsync, MarketplaceService, userId, gamepassId)

	return if success then result else false
end

TextChatService.OnIncomingMessage = function(message: TextChatMessage)
	if message.TextSource == nil then return end

	if userOwnsGamePass(message.TextSource.UserId, GAMEPASS_ID) then
		local properties = Instance.new("TextChatMessageProperties")
		properties.PrefixText = VIP_TAG..message.PrefixText
		properties.Text = message.Text
		properties.Translation = message.Translation
		return properties
	end
end

thank you this worked perfectly!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.