Help with filtering chat

I have made a custom chat system that works just fine, but the only problem is that i need to filter the chat so roblox censor bad words and numbers. I have tried to search for a solution and i have stumbled across text service.
After reading about the text service i have relised that my custom chat is very different from other chat systems. Here is how i made my chat:
Chat:
Elemental slime hunters Work in progress - Roblox Studio 09.08.2022 00_34_04
Objects in local chat:
Elemental slime hunters Work in progress - Roblox Studio 09.08.2022 00_34_21
Objects in server chat:
ChatHandler - Roblox Studio 09.08.2022 00_37_43
Local chat script:


Server chat script:

The problem is that players has different chat settings, someone has safe chat someone has not. So i have to adjust the chat’s for each player and i don’t know how to do that. Is there a simple way to solve this?

You’ll want to look into roblox’s Text Service,

more information is here:

You should try to use Chat:FilterStringForBroadCast() This automatically updates wether people have Safe Chat or not.

Before you fire the event that someone chatted, you should try to do this.

 local msg = game.Chat:FilterStringForBroadCast(player, inputBG.Input.Text)```

Then fire the event.
```lua
if bool and inputBG.Input.Text ~= "" then
serverChats.NewChat:FireServer(msg)
end

I figured out that you need to do input first, then player. And i had to do it in the server script. Anyways, Thank you so much! I’ve struggled with this for too long.

Here is the right way to filter text:

local TextService = game:GetService("TextService")

local newText
local filteredString
local success, errorMsg = pcall(function()
	newText = TextService:FilterStringAsync(Message,Player.UserId)
end)

local filtered, unFiltered = pcall(function()
	filteredString = newText:GetNonChatStringForBroadcastAsync(Player.UserId)
end)

if success and filteredString then
	--send the filtered text here
end	

Message inside the ‘FilterStringAsync’ is the message you want to filter. I mainly use this within remotes.