Argument 2 missing or nil while trying to filter messages

  1. What do you want to achieve?
    I am trying to filter the 2015 chat for a game I’m making.

  2. What is the issue?
    I am getting the error “Argument 2 missing or nil” when I try to send a message.

  3. What solutions have you tried so far?
    I have tried:
    I. Changing the chatMessageDisplayText variable to getFilteredMessage.
    II. Changing the text of the message TextLabel back to getFilteredMessage.


-- Trying to change the chatMessage label itself to filter the message
local chatMessage = Util.Create'TextLabel'
				Name = 'ChatMessage';
				Position =, xOffset, 0, 0);
				Size =, -xOffset, 1, 0);
				Text = getFilteredMessage(chatMessageDisplayText);
				ZIndex = 1;
				BackgroundColor3 =, 0, 0);
				BackgroundTransparency = 1;
				TextXAlignment = Enum.TextXAlignment.Left;
				TextYAlignment = Enum.TextYAlignment.Top;
				TextWrapped = true;
				TextColor3 = this.Settings.DefaultMessageTextColor;
				FontSize = this.Settings.FontSize;
				Font = this.Settings.Font;
				TextStrokeColor3 = this.Settings.TextStrokeColor;
				TextStrokeTransparency = this.Settings.TextStrokeTransparency;
				Parent = container;
-- Changing the variable to try and filter the message
local chatMessageDisplayText = getFilteredMessage(string.rep(" ", numNeededSpaces) .. this:FormatMessage())
-- getFilteredMessage & getTextObject function
local function getTextObject(message, fromPlayerId)
	local textObject
	local success, errorMessage = pcall(function()
		textObject = TextService:FilterStringAsync(message, fromPlayerId)
	if success then
		return textObject
	elseif errorMessage then
		print("Error generating TextFilterResult:", errorMessage)
	return false

local function getFilteredMessage(textObject)
	local filteredMessage
	local success, errorMessage = pcall(function()
		filteredMessage = textObject:GetNonChatStringForBroadcastAsync()
	if success then
		return filteredMessage
	elseif errorMessage then
		print("Error filtering message:", errorMessage)
	return false

I’m just working with the original code I got from a model, and I’m trying to filter it for use with my game. Any potential solutions would be greatly appreciated.