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

Why is this GUI text filtering returning nil even in published game?

I'm not too familiar with how the chat filtering stuff works, so I used a bit of code off the devforums, but still when I try to print the filtered result in an uploaded place, all I get is nil. This is filtered in a server script

Here's the code:

local TextService = game:GetService("TextService") 

local function onSetName(player, text)
	local TEXT_TO_FILTER = text
	local filterSuccess, filterResult = pcall(function() 
  		local filteredTextResult = TextService:FilterStringAsync(TEXT_TO_FILTER, player.UserId) 
   		filterResult = filteredTextResult:GetNonChatStringForBroadcastAsync() 
	end) 
	if not filterSuccess then 
   		warn("Error filtering: ", TEXT_TO_FILTER) 
	else 
		print(filterResult)
	end
end
 

setname.OnServerInvoke = onSetName

Any ideas?

1 answer

Ah, seems like filterResult is nil when inside the pcall, I moved it outside and now it works fine.

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