Text filtering not working properly

Hey! I’m trying to filter a reason in my handcuffs system. However, it does not work properly. It keeps outprinting “false”, meaning that it acts as if everything was filtered (even the word “test” for example). Any idea why that happens?

local function isallowed(stringg, userid)
		if TextService:FilterStringAsync(string, userid):GetNonChatStringForUserAsync(userid) == string then
			return true
		elseif TextService:FilterStringAsync(string, userid):GetNonChatStringForUserAsync(userid) ~= string then
			return false
		end
	end
	
	tr = tostring(tr)
	local check = isallowed(tr, player.UserId)
	if check == true then
		-- code for when its fine, not filtered
	elseif check == false then
		-- code for when its not fine, when its filtered
	end
	print(check)
	print(tr)

FilterStringAsync does not return a string. It returns a TextFilterResult. The documentation provides an example on how you can correctly filter text - both for chat and non-chat strings.

3 Likes

Looking at this again, I realized that you do utilize the TextFilterResult :man_facepalming:. Anyways, perhaps it could be the typo in the isallowed function. The parameter for that function is “stringg” but for the string you pass through FilterStringAsync, you put “string”.

2 Likes

Thanks! Fixed my issue.

(was a pretty bad mistake)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.