Create chat tags with the new TextChatService?

I want to create chat tags in my game using the new TextChatService.

I’m not sure how I would do this.

Thanks for any help.

I have looked on the dev forum and only found a gamepass-locked one, but i don’t want a gamepass locked one.

2 Likes

Hello,

When Roblox announced this feature they included examples of how to do it!

Heres the devforum post. I believe you are looking for the VIP Demo one

6 Likes

I’m trying to give players chat tags based on their username

So for example, if my username is AdSomnum, I’ll get an Owner chat tag

Just add

if player.Name == "AdSomnum" then
--Your code
end

would I do this in a local script in starterplayerscripts?

Yes, or it could go in starter GUI or whatever but I think StarterPlayerScripts would be more realistic.

alright, thank you for your help!

You are absolutely welcome!

Have a great day.

1 Like

I did this

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

TextChatService.OnIncomingMessage:Connect(function(message: TextChatMessage)
	local props = Instance.new("TextChatMessageProperties")
	if Player.Name == "AdSomnum" then
		props.PrefixText = "<font color='#000001'>[Owner]</font> " .. message.PrefixText
	end
end)

in a local script in starterplayerscripts

and it didn’t work

With the part that says prefix text, I don’t think you completed that line fully.

Go back and re read what the full line said.

props.PrefixText = "<font color='#F5CD30'>[VIP]</font> " .. message.PrefixText

that is the line in the VIP script from the forum link

props.PrefixText = "<font color='#000001'>[Owner]</font> " .. message.PrefixText

that is the line in my script

it’s completed i just changed the colour and tag

I’m pretty sure it ends with more of the HTML looking stuff what message.prefixtext.

I would try to be more help but I’m on my phone right now.

i made this (it gives a tag called OG to players who have a badge)

local ogs = {}

game.Players.PlayerAdded:Connect(function(plr)
	local has = game:GetService("BadgeService"):UserHasBadgeAsync(plr.UserId,2126845717)
	if has then
		if not table.find(ogs,plr.UserId) then
			table.insert(ogs,plr.UserId)
		end
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	pcall(function()
		table.remove(ogs,plr.UserId,table.find(ogs,plr.UserId))
	end)
end)

local TextChatService = game:GetService("TextChatService")

TextChatService.OnIncomingMessage = function(message)
	local fromuser = message.TextSource.UserId
	
	local props = Instance.new("TextChatMessageProperties")
	
	if table.find(ogs,fromuser) then
		props.PrefixText = "<font color='#FFFF00'>[OG]</font> " .. message.PrefixText
	end
	
	return props
end

for i,plr in ipairs(game.Players:GetPlayers()) do
	pcall(function()
	local has = game:GetService("BadgeService"):UserHasBadgeAsync(plr.UserId,2126845717)
	if has then
		if not table.find(ogs,plr.UserId) then
			table.insert(ogs,plr.UserId)
		end
		end
	end)
end


1 Like

Hello. You forgot to return the TextChatMessageProperties

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

TextChatService.OnIncomingMessage:Connect(function(message: TextChatMessage)
	local props = Instance.new("TextChatMessageProperties")
	if Player.Name == "AdSomnum" then
		props.PrefixText = "<font color='#000001'>[Owner]</font> " .. message.PrefixText
		return props
	end
end)
1 Like

TextChatService - Chat Tags

    local dev = {}
    local specificPlayer = "username" -- Change to your username

    game.Players.PlayerAdded:Connect(function(plr)
	if plr.Name == specificPlayer then
		table.insert(dev, plr.UserId)
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	for i, id in ipairs(dev) do
		if id == plr.UserId then
			table.remove(dev, i)
			break
		end
	end
         end)

local TextChatService = game:GetService("TextChatService")

    TextChatService.OnIncomingMessage = function(message)
	local fromUser = message.TextSource.UserId

	local props = Instance.new("TextChatMessageProperties")

	if table.find(dev, fromUser) then
		props.PrefixText = "[Developer]" .. message.PrefixText
	end

	return props
end

for _, plr in ipairs(game.Players:GetPlayers()) do
	if plr.Name == specificPlayer then
		table.insert(dev, plr.UserId)
	end
end
1 Like

It is not advised to use your username for stuff like this, as you basically won’t be recognized by the script anymore. Use UserId instead! (i apologize for the necro…)