Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to Apply FilterString to A TextLabel on SurfaceGUI?

So I made a signboard and players can change the text of the textlabel on the surface of the signboard. Players can change the Text of the Textlabel through a TextBox in GUI. I want to apply the Filter so the curse words can be filtered. How do I do that?

2 answers

✓ Accepted answer

plr = game.Players.Era_Gamer

textlabel = "Test Text"

chat = game:GetService("Chat")

local filter = chat:FilterStringForBroadcast(textlabel,plr)

print(filter)

-- Output: Text Text

2 comments

0

Change "Test Text" to the text in TextLabel, change plr to whatever player you're talking about (may end up using game.Players.PlayerAdded for this), don't mess with filter, and use return instead of print, or directly make the text the filter.

1

Thanks for the help. I never thought it was so simple

You could use RemoteEvent which I fiind it very helpful. Even though you can filter through local scripts I still use the "old" way I guess

--Inside Script
local RE = Instance.new('RemoteEvent', game:GetService('ReplicatedStorage'))a
RE.Name = 'FilterEvent'
RE.OnServerEvent:connect(function(Player, String)
String = game:GetService('Chat'):FilterStringAsync(String, Player, Player)
print(Player.Name..': '..String)
--Do your stuff here
end)

How to use it:

--Inside Local
local RE = game:GetService('ReplicatedStorage'):WaitForChild('FilterEvent')
--When you want to filter a string
RE:FireServer(StringHere)

This discussion is preserved as it was. New answers, comments, and votes are closed.