So, I have a custom chatbox that requires filtration since, well it’s a chatbox. For some reason though, it keeps returning this error message even after ~1hr of searching. I really wanna fix this before making the rest of my game, so any help would be appreciated.
Solutions I tried were reading the devhub page for it (most of it just fell out the other ear though so that may be on me), trying to debug it myself which you can still see in the code, and pretty much copying the code from Polyheximal’s post (A Guide to Filtering Text). After none of those worked I then stripped it all down to what I thought was strictly necessary for my implementation to make it easier to debug, and still couldn’t figure it out.
Any help is appreciated, plus tips on a chat system.
Filter script:
local TextService = game:GetService("TextChatService")
local event = script.filter
local function getFilterResult(plr, text)
local filterResult
print("pretest")
local success, errorMessage = pcall(function()
filterResult = TextService:FilterStringAsync(text, plr.UserId):GetNonChatStringForBroadcastAsync()
print(filterResult)
end)
if success then
script.filter:FireClient(plr.UserId,text)
else
warn("Error generating TextFilterResult:", errorMessage)
end
end
event.OnServerEvent:Connect(getFilterResult)
Excerpt from the chat gui script that fires the event for filtering:
function Chat:PlayerChat(message)
print(message)
event:FireServer(message)
event.OnClientEvent:Connect(function(msg)
if msg then
print("plrchat")
local m = Instance.new("StringValue")
m.Name = "NewMessage"
m.Value = msg
m.Parent = game.Players.LocalPlayer
game:GetService("Debris"):AddItem(m, 2)
end
end)
end
Don’t mind the prints, I attempted debugging it myself multiple times too.