How to Remove a Chat bubble for certain Messages not all

Hey developers! The title explains itself. But what I am wondering is how can I stop a bubble from appearing on the client. I have a system that flags certain messages and I haven’t been able to figure out how to “disable” the bubble for those messages.

Any help is much appreciated!

3 Likes

Here’s a basic example I had a few years ago (a friends):

local ChatService = game:GetService("Chat")
local ChatBar = game:GetService("Chat")
local function sendMessage(player, message, disableBubble)
    local messageTable = {
        Text = message,
        FromSpeaker = player.Name,
        Color = Color3.new(1, 1, 1), -- Change this to the desired text color
        Font = Enum.Font.SourceSans,
        TextSize = 18,
        ChatColor = disableBubble and Color3.new(0, 0, 0) or Color3.new(1, 1, 1),
    }

    local channel = ChatService:AddChatChannel("CustomChannel")
    local chatBubbleMessage = ChatService:GetChatForUserAsync(player, channel.Name, messageTable)
    ChatBar:Chat(chatBubbleMessage, channel.Name)
end
local player = game.Players.LocalPlayer -- Change this to the appropriate player
local message = "This message won't have a chat bubble"
sendMessage(player, message, true)
2 Likes

Hey thanks for the reply. I notice that this script is Using Chat Service and not Text Chat Service which uses deprecated methods.

I have a script Kinda which looks like this:

local TextChatService = game:GetService("TextChatService")
local Flagged = false -- this changes in the script. Not provided But I promise it does change
TextChatService.OnIncomingMessage = function(Message : TextChatMessage)
	print("Fired!")
	if Message.TextSource.UserId == game.Players.LocalPlayer.UserId and Flagged then
--Hide Bubble here
    end
end

I tried a couple things in your script but using the more Up to date version of the methods but I didn’t quite understand your script as I haven’t really used Chat Service (Since I kinda started scripting with TextChatService, and often I personally don’t mess with the roblox chat system).

local TextChatService = game:GetService("TextChatService")
local Flagged = false

TextChatService.OnIncomingMessage:Connect(function(Message)
    print("Fired!")

    if Message.TextSource.UserId == game.Players.LocalPlayer.UserId and Flagged then
        local extraData = Message:GetExtraData()
        extraData.BubbleChatColor = Color3.new(0, 0, 0) -- Set chat bubble color to black
        Message:SetExtraData(extraData)
    end
end)

Should fix the issues up…

"GetExtraData is not a valid member of TextChatMessage “Instance” "

By doing this:

local extraData = Instance.new("BubbleChatMessageProperties")
			extraData.BackgroundColor3 = Color3.new(0, 0, 0) -- Set chat bubble color to black
			extraData.TailVisible = false
			
			Message.BubbleChatMessageProperties = extraData

Just makes it a black bubble… And not remove the bubble entirely like what I am hoping for
image

Message.BubbleChatMessageProperties.BackgroundColor3 = Message.TextColor

That will set the background color of the message to the text color, which should fix it. (it’s impossible to what I know to fully delete a message)

1 Like