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:
Objects in local chat:
Objects in server chat:
Local 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?
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.
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.