How would i add filtering to a Chat message?

Please note that I am NOT making a UTG instead i am using other things and has a unique name. This is a more friendly version of it

  1. What do you want to achieve? Keep it simple and clear!
    I need to make a filtered string for my chat menu on my trolling gui
  2. What is the issue? Include screenshots / videos if possible!
    I don’t know how to filter and i don’t want to add 100 lines of code to my 6 lines of code
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i tried the DevHub one but it has too many lines for my liking

I have made this script but i don’t know why it keeps saying “Instance” whenever i put in chat

game.ReplicatedStorage.SayChat.OnServerEvent:Connect(function(plr, victim, chat)
	local TS = game:GetService("TextService")
	local victiminstance = game.Players:FindFirstChild(victim)
	local fixedchat = TS:FilterStringAsync(chat, plr.UserId)
	game.Chat:Chat(victiminstance.Character, fixedchat, 1)
end)

I believe this should work.

game.ReplicatedStorage.SayChat.OnServerEvent:Connect(function(plr, victim, chat)
	local TS = game:GetService("TextService")
	local victiminstance = game.Players:FindFirstChild(victim)
	local fixedchat = TS:FilterStringAsync(chat, plr.UserId)
    local result = fixedchat:GetNonChatStringForBroadcastAsync(player.UserId)
	game.Chat:Chat(victiminstance.Character, result, 1)
end)

The line I added

local result = fixedchat:GetNonChatStringForBroadcastAsync(player.UserId)

This should give the text iself.

1 Like