I am using TextService
to use as a filter for my radio, although I am not sure how to use it.
The radio works by the client sending what it said by an event and then the server script sends all the clients the message. I am filtering the chat in the server. How can I solve this issue?
Before I used some other code to filter it looked like this:
local function filterMessage(text, id)
local filteredMessage
local success, errorMessage = pcall(function()
filteredMessage = TextService:FilterStringAsync(text, id)
end)
if not success then
warn("Error filtering text:", text, ":", errorMessage)
return
end
return filteredMessage
end
It always returned nil so my friend said to do this:
local function filterMessage(text, id)
local textFilterResult = " "
local filteredMessage = " "
local success, errorMessage = pcall(function()
textFilterResult = TextService:FilterStringAsync(text, id)
filteredMessage = textFilterResult:GetChatForUserAsync(id)
--print("Filtered text: "..filteredMessage)
end)
if not success then
warn("Error filtering text:",tostring(text), ":", errorMessage)
return
end
return filteredMessage
end
But that did nothing and still let the message go by.