FilterStringAsync() returning instance and not a string

  1. What do you want to achieve? Keep it simple and clear!
    Im trying to filter some text thats all.

  2. What is the issue? Include screenshots / videos if possible!

My issue is that. When i invoke the server which then calls a function to filter text. It filters it. But for some reason it returns an instance and not a string… Im getting this error message “invalid argument #3 (string expected, got nil)”

Heres my code atm:

– // CLIENT:

local FUNC = game.ReplicatedStorage:WaitForChild("FUNCS", true).FILTER


script.Parent.FocusLost:Connect(function(Enter)
	if Enter == true then
		if #script.Parent.Text > 0 then
			local RES = FUNC:InvokeServer(script.Parent.Text)
			script.Parent.Parent.Parent["TEXT 1"].Text = RES
		else
			script.Parent.Text = "TEXTBOX IS EMPTY!"
			wait(0.5)
			script.Parent.Text = "TEXT 1"
		end
	end
end)

– // SERVER

local FILTER = game.ReplicatedStorage:FindFirstChild("FUNCS").FILTER
local SERVICE = game:GetService("TextService")


FILTER.OnServerInvoke = function(PLAYER, TEXT)
	local FILTERED = nil
	local SUCESS, ERR = pcall(function()
		FILTERED = SERVICE:FilterStringAsync(TEXT, PLAYER.UserId)
	end)

	
	if not SUCESS then
		error(ERR)
		return "COULDNT FILTER STRING. THERE FOR WE CATN USE IT!"
	else
		return FILTERED
	end
end

You should maybe read the documentation on FilterStringAsync().
It returns a TextFilterResult.

To get the contents of it, you have three options.

GetChatForUserAsync(), which is for private chats.

GetNonChatStringForBroadcastAsync(), which is for non-chat strings that will be shown to all users, such as a name of a pet.

GetNonChatStringForUserAsync(), which is for a non-chat string that is shown to one user, like a pet name that is only visible to the user.

1 Like