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: