Hiding chats from a textchatservice channel

No idea to be honest, it supposed to just stop it from sending?

lmao so we’re on the same page

1 Like

I have debugged this further and still no trace of deletion shown:

local logsChannel = TextChatService:WaitForChild("TextChannels"):WaitForChild("Logs")

logsChannel.OnIncomingMessage = function(message)
	print("OnIncomingMessage triggered")
	local properties = Instance.new("TextChatMessageProperties")

	if message.TextSource then
		print("Message has TextSource")
		local player = Players:GetPlayerByUserId(message.TextSource.UserId)
		if player then
			print("Message from player: " .. player.Name)
			properties.Text = ""
			print("Message hidden")
			return properties
		else
			print("Message from non-player or unknown user")
		end
	else
		print("Message has no TextSource")
	end

	print("Allowing message to pass through")
	properties.Text = message.Text
	return properties
end

Prints:

  16:34:46.424  OnIncomingMessage triggered  -  Client - ChannelsManager:34
  16:34:46.424  Message has TextSource  -  Client - ChannelsManager:38
  16:34:46.424  Message from player: TeamDreams123 -  Client - ChannelsManager:41
  16:34:46.424  Message hidden  -  Client - ChannelsManager:43
  16:34:46.504  OnIncomingMessage triggered  -  Client - ChannelsManager:34
  16:34:46.504  Message has TextSource  -  Client - ChannelsManager:38
  16:34:46.504  Message from player: TeamDreams123 -  Client - ChannelsManager:41
  16:34:46.504  Message hidden  -  Client - ChannelsManager:43

Also I have no idea why the prints happen twice.

Nothing I have tried is working. I need someone else to help me with this (preferably someone who is experienced with TextChatService)

This is becoming a massive error for our game. Needing urgent help now.

Still a critical error. Will continue to bump this until someone notices it.

serverscript:

local chat = game:GetService("TextChatService")
local channel = chat:WaitForChild("TextChannels"):WaitForChild("Logs")

channel.ShouldDeliverCallback = function(message, source)
	if message.TextSource then
		local sentByPlayer = PS:GetPlayerByUserId(message.TextSource.UserId)
		if sentByPlayer then
			return false
		end
	end
	return true
end

but the localplayer can still send messages there even if no one can see them this is my workaround
localscript:

local chatWindowConfiguration = TextChatService.ChatWindowConfiguration
TextChatService.OnChatWindowAdded = function(message: TextChatMessage)
	if message.TextSource then
		if message.TextChannel.Name ~= 'Logs' then return end

		if message.TextSource.UserId == Players.LocalPlayer.UserId then
			local properties = chatWindowConfiguration:DeriveNewMessageProperties()
			properties.PrefixText = " "
			properties.Text = " "
			return properties
		end
	end
end

What is the ‘ps’ definining?

Nevermind, I found out. It’s the ‘players’ service

Also do you know a way to disable bubble chat?

@a19_9 do you know how to disable bubble chat for that chat channel too?

And, just in case it’s been missed out:

If you want to have channels for system-generated messages, that players can view, how about just adding players to the channel and changing their TextSource.CanSend property to be false?

I’ve done that. Didn’t work. But do you know how to disable bubble chats?

In a little more depth, I enabled it but still on the client that the player sends it on they still recieve the message. Could you give me some code?

That is odd.

Then I’m guessing RBOLOX has made the mistake of having these properties heavily based on the client-side UI responsible for double-checking these properties. As a result of this, I’ll make an addition to WinryChat 1.5 to add support for TextSource.CanSend.

The fact these bugs are appearing (at an alarming rate) for TextChat is disconcerting for the QA and QC of the Core UI development team.

My question still stands, do you know how to disable the bubble chats from that script?

I’ll look into it thoroughly and come back once I have a working solution, as I’m planning to add support for that in WinryChat anyway.

1 Like

Figured something out yet?

Just an update on what I’ve got so far:

  1. You need to set BubbleChatConfiguration.Enabled to false - This will disable the default bubble chat and stop us from having problems.

  2. You need to custom-setup each bubble with TextChatService:DisplayBubble() - This is client-sided only, so others won’t see messages if they aren’t supposed to.

ROBLOX has tried hard to make it so you can’t just do custom visibility bubble chats, but they’ve left an endpoint open to still hide them entirely due to NPCs needing to talk. Test images & script:



This does open up some possibilities of Per-Bubble Customization to indicate which chat channel is being spoken in.

But that would completely disable all bubble chats from other players and all channels? Maybe a custom one would be better.

You’ll be using DisplayBubble client-sided in conjunction with a custom chat system if you go that route.

That’s the only way I can find to do it, and it’s a way to use the API to hide bubble chat messages from players without access to a specific channel.

Maybe you could do it so if a player has a rank in something like group id 1 and it is 255 then it will hide bubble chat messages to that specfic channel? I’m not the best with textchatservice

That would effectively be up to 255 text channels automatically created when the server loads.

You would still need to disable the default bubble chat and build DisplayBubble into the chat system instead. The only difference being that you use a server-context script (Default/Server) to get your group’s info and create text channels for each rank. Then you would only add players to:

  • A Global/General Chat
  • A Staff Chat (if you’re doing a homestore/cafe/hangout area)
  • A Chat for the group rank of the player.

You would also add each player manually to any other chats they need to have access to (i.e. Admins and Owners get Moderator Chat access if necessary).

This has already been done, except for the one I highlighted. The logs channel needs to have access to everyone above rank 6, since our server size is 35, we need mods to be able to communicate with eachother privately.

Could you give me some code based off of the one I provided below?

local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local logWelcomeEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("Other"):WaitForChild("LogEvent")
local staffWelcomeEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("Other"):WaitForChild("StaffEvent")

local function createStaffChannel()
	local staffChannel = Instance.new("TextChannel")
	staffChannel.Name = "Staff"
	staffChannel.Parent = TextChatService:WaitForChild("TextChannels")
end

local function createLogsChannel()
	local logsChannel = Instance.new("TextChannel")
	logsChannel.Name = "Logs"
	logsChannel.Parent = TextChatService:WaitForChild("TextChannels")
end

local function addPlayerToStaffChannel(player)
	if player:GetRankInGroup(8423759) >= 6 then
		local staffChannel = TextChatService:WaitForChild("TextChannels"):WaitForChild("Staff")
		if staffChannel then
			staffChannel:AddUserAsync(player.UserId)
			staffWelcomeEvent:FireClient(player, "Hello %s! Only staff can see and type in this channel.")
		end
	end
end

local function addPlayerToLogsChannel(player) -- adding them to the logs channel
	if player:GetRankInGroup(8423759) >= 6 then
		local logsChannel = TextChatService:WaitForChild("TextChannels"):WaitForChild("Logs")
		if logsChannel then
			local textSource = logsChannel:AddUserAsync(player.UserId)
			textSource.CanSend = false
			logWelcomeEvent:FireClient(player, "Hello %s, in this channel (logs) you are not allowed to send messages. These are for flagging events and other actions to assist in moderation.")
		end
	end
end

createStaffChannel()
createLogsChannel() -- create logs

Players.PlayerAdded:Connect(function(player)
	addPlayerToStaffChannel(player)
	addPlayerToLogsChannel(player) -- add player to logs
end)

for _, player in Players:GetPlayers() do
	addPlayerToStaffChannel(player)
	addPlayerToLogsChannel(player) -- add player to logs
end

local channel = TextChatService:WaitForChild("TextChannels"):WaitForChild("Logs")

channel.ShouldDeliverCallback = function(message, source) -- removes logs messages
	if message.TextSource then
		local sentByPlayer = Players:GetPlayerByUserId(message.TextSource.UserId)
		if sentByPlayer then
			return false
		end
	end
	return true
end

Commented for you :wink: