Filter text not working

local function filterMessage(msg, fromUser)
	local result
	local success, err = pcall(function()
		result = TextService:FilterStringAsync(msg, fromUser)
	end)
	if success then
		return result
	end
	return false
end



local gui = owner.PlayerGui.ClanGui.CreateClanFrame
	local filter = filterMessage(clanName, owner)
	if filter == false then
		print("text was filtered")
		gui.create.Text = "Error: Innapropriate clan name."
	else
		print("text was not filtered")
		owner.ownsClan.Value = true
		owner.Clan.Value = clanName
		addClanInstance(clanName, owner)
		local dataToSave = {owner.UserId, clanName}
		CLANS:SetAsync(owner.UserId, dataToSave)
		print("saved "..owner.UserId, clanName)
		gui.create.Text = "Clan "..clanName.." created!"
		wait(2)
		gui.Visible = false
	end
end)

That code does not work, it will filter everything.
I have already tried tutorials on the devforum and they don’t seem to work for me, and they still filter everything.

1 Like

Scripting support is not for full blown scripts, but more as fixing a script that isn’t working already. If you made a new post with your old code that wasn’t working then we can help!

You can compare the result of this to the original string, and if they are not identical, you know the string has been filtered in some way.

That does not work, it still filters everything.

Can you clarify on what you mean by “it filters everything”?

Well, when I add print(“text was not filtered”) to the part where you would put it if the text wasn’t filtered, then it does not print

As @acuaro said, don’t be posting your full scripts. I am not interested in looking into your whole script to find your error, try printing and seeing which specific part isn’t working.

That’s because it will only return “error” if there was an actual error in the process.

How would I make it print “text was not filtered” and “text was filtered”?

Refer to this post I made earlier.

That does not work, as I have already said.

Can you send a snippet of code so I can see what it’s doing?