Filtering text Help

Hello, I am trying to use the TextService:FilterStringAsync() to filter words/string, However the 2nd parameter needs a player userID. Is there a way to filter text without having to use a player’s userID?

TextService:FilterStringAsync( word, userID )

For example, let’s say I made a random word generator that runs on the server-side. and I want to filter this random word. What am I gonna put for the Userid?

Heres my code:

local function filter(sentence)
local filteredTextResult
local filteredText
if sentence ~= "" then
	
	
	local success, errorMessage = pcall(function()
		filteredTextResult = TextService:FilterStringAsync(sentence, 110538855) -- this is my id, replace it with yours  
		filteredText = filteredTextResult:GetNonChatStringForBroadcastAsync()
	end)
	
	
	if success then
		return(filteredText)
	else
		print(errorMessage)
	end
	
end
end
1 Like

hmm did you try it without entering any user id?

yes I tried, it returns an error saying that the 2nd parameter is missing

This method currently throws if fromUserId is not online on the current server. We plan to support users who are offline or on a different server in the future.

No, currently it’s not possible. Why can’t you pass a userID though? Whose text do you need to filter?

well you have to publish the game and see if it works, you can’t see if the text is filtered in studio.

@tlr22 he is making a random word generator on the server

1 Like

I get the same results when published

Currently it’s not possible. And it seems that even if they add support for offline users in the future, you will end up needing to pass an ID in still.

1 Like

Why not use FilterNonChatStringforbroadcastasync? Or something like that. This doesn’t use a userID.

1 Like

its, :GetNonChatStringForBroadcastAsync() and thats getting the text from TextService:FilterStringAsync(sentence, player.UserId)

Thanks for responding though

1 Like