How to use textchatservice?

Could someone please make me a script on how to give a player a chat tag because i tried everything, i even used AI but nothing seems to work

use documentation; simple as hell

i already did nothing works on god

what do you mean “νοτηινγ ςορκσ”??

i dont even speak that language

I had the same headache a few months ago, and I found a simple way to explain.

When a message is sent, a callback named “OnIncomingMessage” will fire. So if you make a callback like this:

game:GetService("TextChatService").OnIncomingMessage = function(Message)
-- your code here
end

You’ll be able to fetch any incoming message showing on the client.

Basically, each message has those properties that can be handy for your case:

  • TextSource, which indicates who sent the message. You can use it to get the player who spoke and obviously the rank.
  • Text, which is what (like [Vikko151]: hi). You can use rich text to change the color and such.
  • PrefixText, which is a space to put something before the message. If you want to indicate the rank, this might be very helpful.

With this you should be able to use TextChatService without headache.

local Players = game:GetService(“Players”)
local TextChatService = game:GetService(“TextChatService”)

local playersWithTag = {}

local function onPartTouched(hit, part)
local humanoid = hit.Parent:FindFirstChild(“Humanoid”)
if humanoid then
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player and not playersWithTag[player.UserId] then

        playersWithTag[player.UserId] = true
        print(player.Name .. " has received a chat tag!")
        
  
    end
end

end

local function setupTagGiver()
local tagGiver = workspace:FindFirstChild(“TagGiver”)
if tagGiver then
tagGiver.Touched:Connect(function(hit)
onPartTouched(hit, tagGiver)
end)
print(“TagGiver part found and connected!”)
else
warn(“TagGiver part not found in workspace!”)
end
end

setupTagGiver()

TextChatService.OnIncomingMessage = function(message)
local textSource = message.TextSource
if textSource then
local player = Players:GetPlayerByUserId(textSource.UserId)
if player and playersWithTag[player.UserId] then

        message.PrefixText = '<font color="#FFD700">[VIP]</font> ' .. message.PrefixText
        
     .. player.Name .. ']</font>:')
    end
end

return message

end
Players.PlayerRemoving:Connect(function(player)
playersWithTag[player.UserId] = nil
end)

I used this script for example with the thing you sent but it still doesn’t work