Filtering Strings

Im just trying to filter a String. Ive been through like 20 different threads and none of them work. Ive got a custom shout’s in-game. They type the desired message into a GUI and the GUI sends data to the server with the player and their desired message. The server then filters the message and does :FireAllClients() to have the little announcement UI show up. But its not. Somebody help, ive been at it for like 2 hours now.

Edit: Im stupid, and filtered the wrong text.

1 Like

Could you show the code that handles filtering the announcement text and the client code for showing the announcement UI?

Are there any errors being outputted?

1 Like

If you’re testing in Studio, Studio won’t filter the message. Otherwise, show us your code that you used to filter the string.

Try using TextService:FilterStringAsync(), keep in mind that it must be called by the server.

local myString = 'some text'
local recipient = 123456 -- recipient's user ID, must be connected to server
local recipientType = 'PublicChat' -- can be PublicChat or PrivateChat
local filteredObject = game:GetService('TextService'):FilterStringAsync(myString, recipient, recipientType)

local filteredText = filteredObject:GetNonChatStringForBroadcastAsync() -- the actual string

Have you tried using the FilterStringForBroadcast method of the Chat service? It takes the text to filter, and the speaker who said the text.

local Speaker = game.Players.Player;
local Text = "Hello World! How are you?";

local FilteredText = game.Chat:FilterStringForBroadcast(Text, Speaker);
print(FilteredText); -- Filtered text outputted