How to turn off notifications from joining teams?

Hey guys. My obby game has a round system, so some players will be in the lobby team while others will be in the obby team. I want it so that the chat doesn’t constantly notify them when they join another team in the chat.
There is no property for it, so I’m not sure how to get this to work.
I checked for anything on the documentation and the dev forums, but I couldn’t find anything.

Is there a workaround for this in code?
Thanks for helping!

1 Like

It’s something deep in the core scripts, I don’t think you can get rid of it, sadly… idk, there might be a way.

1 Like

Normally I’d say make your own team system, but this was actually surprisingly easy to do.

Assuming you are using TextChatService and not the old legacy chat, we can use OnIncomingMessage to block these specific messages.

local TextChatService = game:GetService("TextChatService")

function BlockTeamMessage(TextChatMessage: TextChatMessage)
	local MessageProperties = Instance.new("TextChatMessageProperties")
	
	local MessageContent = TextChatMessage.Text
	local Source = TextChatMessage.TextSource
	
	-- // Check if a player sent it, if they did, then dont block it.
	if Source then 
		return
	end
	
	-- // Is this system message the team message?
	local TeamMatch = string.match(MessageContent, `You are now on the '[%w]+' team.`)
	
	-- // If it is, just... dont show it.
	if TeamMatch then
		MessageProperties.Text = " "
	end
	
	return MessageProperties
end

TextChatService.OnIncomingMessage = BlockTeamMessage
3 Likes

It seems like the core scripts have something to protect their chat messages.

I gave it a go myself, using string.match, string.find, etc. to check if it matched up with the messages to ignore. I used a print statement to tell me if it matched to those messages or not, and the statement printed each time, although the Properties.Text didn’t override the message (it showed in chat).

I’m not too sure, might just be an issue on my end.

Edit: sounds like it was, studio reinstalled and it worked.

The text does not show (Which is good!!!), but for some reason there are notifications that still show (The number on the top right of the chat button icon). There is no message, but it still thinks that there is a message. Is there a way to stop the number on the top right of the icon from appearing specifically when it’s a message for switching teams?

The message itself still exists - the text has just been set to blank. You could try calling Destroy() on the message instance, otherwise I don’t think there’s any other way. Good luck, it’s a pain to get rid of these things.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.