Ive set up these two functions so that when a remote event and function are triggered, certain functions happen that filter the text and give it back to the player in a text label. When I test this ingame I get the following error:
-- Error filtering message: ServerScriptService.TextFilter:27: attempt to index global 'text' (a nil value)
And here is the script in ServerScriptService:
local summary = game.ReplicatedStorage.Summary.Value
function Filter()
local TextService = game:GetService("TextService")
local sumname = game.ServerStorage.Summarizer.Value
local summarizer = game.Players[sumname].UserId
local filteredMessage = ""
summary = game.ReplicatedStorage.Summary.Value
success, errorMessage = pcall(function()
text = TextService:FilterStringAsync(summary, summarizer)
end)
if success then
return text
elseif errorMessage then
print("Error filtering message:", errorMessage)
end
end
game.ReplicatedStorage.FilterEvent.OnServerEvent:Connect(Filter)
function sendFiltered()
wait (0.1)
local TextService = game:GetService("TextService")
local sumname = game.ServerStorage.Summarizer.Value
local filteredMessage = ""
success, errorMessage = pcall(function()
filteredMessage = text:GetNonChatStringForBroadcastAsync()
end)
if success then
return filteredMessage
elseif errorMessage then
print("Error filtering message:", errorMessage)
end
return false
end
game.ReplicatedStorage.Filter.OnServerInvoke = sendFiltered()
Thanks in advance for the help!

3 comments
I'm pretty sure this isn't your fault. Since you can't control filtering, This just means the service is down. Right now (Friday-Saturday) is a really common time for this to happen, so just wait a while and it should be back.
Alright, thanks ^
Line 36 is wrong. You need to remove the () as this is assigning OnServerInvoke to false, or the returned message. By removing the () you are assigning OnServerInvoke to the function itself and not what it returns.