Detecting whisper/team chat via ChatService and then adding onto the message

I’m using this piece of code to detect player messages using the ROBLOX ChatService, this works fine for messages in public channels like “all” however it does not seem to trigger when in team chat. How do I go about detecting messages sent in team chat? I couldn’t find anything in the documentation. I’m trying to add a piece of information to the team chat.

local function HandleSpeakerAdded(playerName: string)

    local speaker = ChatService:GetSpeaker(playerName)

    speaker.SaidMessage:Connect(function(messageObject, channelName)
        print(messageObject, channelName)

1 Like

You can use .Chatted instad like this:

    player.Chatted:Connect(function(message, recipient)

if there is “recipient” then it is because it is in a DM. that way you can identify if it is a PM or not. And yes this will work for Team chat too.

1 Like

That works and answers my initial question, thank you.
However I forgot that the whole point was to intercept the message so I can add a piece of information to it before it is replicated to the other clients.

Like so:
{TEAM}[AgentVanBur]: (piece of information) chat message

1 Like

oh! for that you will do the next thing:

the “message” variable when used in team will have “/t” at the start. So that way by splitting a string you can know if it is being sent in a team.

Appart from that you can get the team of the player by using the “player” variable in game.Players.PlayerAdded event. You will do:

player.Team.Name --Name
player.TeamColor --Brick Color

that way you can get the team name and the color of the team. Hope that answers your question!

Thanks but that isn’t the solution unfortunately. As I said above I’m trying to add a piece of text before the message and that simply isn’t possible using Chatted.