I made this auto-recruiting bot for an upcoming game of mine, whatever text you insert in a textbox a clone of yourself spawns walking around saying that message. One issue is it bypasses words that should be tagged, I have already tried it with many words and it does not get tagged. How could I go on about this? (This is also in-game not in-studio)
I have not tried any scripts to prevent this since I have no idea how to…
It is not supposed to be “tagged.” The only thing that is automatically filtered is Roblox’s chat system. You can filter text manually yourself using the TextService or the Chat service. They both have text filtering functions.
This runs from ChatService… I will try that.
This maybe be a bad method but couldn’t ypu try like this? You gotta use a lot of if statements but it could work, and sorry I am on my phone.
local Banned_Words = {"test"}
local Bot = game.workspace.Bot
if Bot.Dialog.Text == Banned_Words[1] then do
Bot:Destroy()
end)
Good idea, but the number of words that I would have to tag would be insane. Especially when people change their text by adding another word even though you can still make out the word they intended to say.
This is against the rules. You need to use Roblox’s filter system on top of any filters of your own, which ruins the point of having this at all.
I’m saying that Daffy and Phoenix’s “solutions” are against the rules. I’m aware you know that not filtering isn’t an option either. This is really simple, just run the text through FilterStringAsync before displaying it anywhere. (I wouldn’t use the Chat service’s functions, since they’re partially deprecated.)
Quick example of how it’s used:
local textService = game:GetService("TextService")
local result = textService:FilterStringAsync(YOUR_MESSAGE, THE_PLAYER_SENDING_IT.UserId)
local chatMessage = result:GetChatForUserAsync(THE_PLAYER_VIEWING_IT.UserId)
Here, chatMessage
would be the filtered text. There are other functions you could call on result
, for other situations, which are shown at TextFilterResult. Keep in mind you would have to filter it separately for each player as a different “THE_PLAYER_VIEWING_IT”, so it’s probably better to filter it in the LocalScript of the player viewing it.
Last question, doesn’t the FilterStringAsync require 3 arguments? I also cannot get my current script to work as I get a error saying
Unable to cast value to Object
The portion I add my script to.
Remote.OnServerEvent:Connect(function(Player,Messages,Cost,Duration,Speed)
local result = ChatService:FilterStringAsync(Messages, Player, Player)
local chatMessage = result:GetChatForUserAsync(Player.UserId)
Your error is because both functions take a UserId, not a Player.
The third parameter for FilterStringAsync should be a TextFilterContext
Enum, but it’s optional. It defaults to Enum.TextFilterContext.PrivateChat
. Also, the player for GetChatForUserAsync
should be the user who’s seeing the message, not the person sending. That’s why I put THE_PLAYER_VIEWING_IT
and THE_PLAYER_SENDING_IT
separately in my mock-up.
Lastly, once you do this, make sure to test IN GAME. Roblox does not filter inside studio so it will appear as if it does not work, when in reality it does, you just need to test in an actual game.
My script is now
local result = ChatService:FilterStringAsync(Messages, Player.UserId, Enum.TextFilterContext.PublicChat)
local chatMessage = result:GetChatForUserAsync(game.Players) -- no clue how to call this from a ServerScript
If it does not work either, send us a screenshot of the error at the Output.
Because :GetChildren
returns an array of player instances. You need to get the user ID of a specific player.
You need to pass in a single player, your script is using a table of players. Also since this is text that is being shown to everyone you might want to use TextFilterResult:GetNonChatStringForBroadcastAsync( )
since that applies the filter in a more strict manner for all users.
Here is a reply I made in an older post on how to use the filter:
I tried this type of code:
ChatService:FilterStringAsync(Player.Id, Messages)
TextFilterResult:GetNonChatStringForBroadcastAsync() -- how can I define this?
The global is not defined here.
local tfResult = game:GetService("TextService"):FilterStringAsync(message, player.UserId)
local filteredText = tfResult:GetNonChatStringForBroadcastAsync()
Testing in-game, I still was able to bypass is there anything wrong with my script?
ChatService = game:GetService("Chat")
Remote.OnServerEvent:Connect(function(Player,Messages,Cost,Duration,Speed)
local tfResult = game:GetService("TextService"):FilterStringAsync(Messages, Player.UserId)
local filteredText = tfResult:GetNonChatStringForBroadcastAsync()
It depends, are you sure that filteredText
is what you are putting in the chat bubble? Just defining the variable won’t do anything.