-
What do you want to achieve?
I am trying to filter the 2015 chat for a game I’m making. -
What is the issue?
I am getting the error “Argument 2 missing or nil” when I try to send a message. -
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.
Code:
-- Trying to change the chatMessage label itself to filter the message
local chatMessage = Util.Create'TextLabel'
{
Name = 'ChatMessage';
Position = UDim2.new(0, xOffset, 0, 0);
Size = UDim2.new(1, -xOffset, 1, 0);
Text = getFilteredMessage(chatMessageDisplayText);
ZIndex = 1;
BackgroundColor3 = Color3.new(0, 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)
end)
if success then
return textObject
elseif errorMessage then
print("Error generating TextFilterResult:", errorMessage)
end
return false
end
local function getFilteredMessage(textObject)
local filteredMessage
local success, errorMessage = pcall(function()
filteredMessage = textObject:GetNonChatStringForBroadcastAsync()
end)
if success then
return filteredMessage
elseif errorMessage then
print("Error filtering message:", errorMessage)
end
return false
end
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.
Thanks,
OldBo5.