DoProcessCommands Function 'message_validation' failed for reason: Chat.ChatModules.ChatMessageValidator:58: attempt to index nil with 'GetPlayer'

Hello!

I’m trying to create a fake server speaker that sends a randomly generated message every few minutes. The problem is that I’m encountering the issue in the title. Not sure why. Also note that I am not forking the chat. The output is a warn, not an error.

local serverScriptService = game:GetService('ServerScriptService')

local chatServiceRunner = serverScriptService:WaitForChild('ChatServiceRunner')

local chatService = require(chatServiceRunner:WaitForChild('ChatService'))
local speaker = require(chatServiceRunner:WaitForChild('Speaker'))

local speakerObject = speaker.new(chatService, 'ServerTest')

local channel = chatService:GetChannel('All')
channel.Joinable = true
channel.AutoJoin = true

print(speakerObject)

speakerObject:JoinChannel('All')
speakerObject:SayMessage('Hi', 'All', {})

print(speakerObject) prints the following:

               ["Channels"] = {},
                    ["ChatService"] =  ▼  {
                       ["ChannelAdded"] = Signal Event,
                       ["ChannelRemoved"] = Signal Event,
                       ["ChatChannels"] =  ▼  {
                          ["all"] =  ▼  {
                             ["AutoJoin"] = true,
                             ["ChatHistory"] = {},
                             ["ChatService"] = "*** cycle table reference detected ***",
                             ["Destroyed"] = Signal Event,
                             ["FilterMessageFunctions"] =  ▼  {
                                ["FunctionMap"] = {},
                                ["RegisteredFunctions"] = {},
                                ["RegisteredPriorites"] = {}
                             },
                             ["GetWelcomeMessageFunction"] = "function",
                             ["HistoryIndex"] = 0,
                             ["Joinable"] = true,
                             ["Leavable"] = false,
                             ["MaxHistory"] = 200,
                             ["MessagePosted"] = Signal Event,
                             ["Mutes"] = {},
                             ["Name"] = "All",
                             ["Private"] = false,
                             ["ProcessCommandsFunctions"] =  ▼  {
                                ["FunctionMap"] =  ▼  {
                                   [20] =  ▼  {
                                      ["default_commands"] = "function"
                                   }
                                },
                                ["RegisteredFunctions"] =  ▼  {
                                   ["default_commands"] = 20
                                },
                                ["RegisteredPriorites"] =  ▼  {
                                   [1] = 20
                                }
                             },
                             ["SpeakerJoined"] = Signal Event,
                             ["SpeakerLeft"] = Signal Event,
                             ["SpeakerMuted"] = Signal Event,
                             ["SpeakerUnmuted"] = Signal Event,
                             ["Speakers"] = {},
                             ["WelcomeMessage"] = "{RBX_LOCALIZATION_KEY}GameChat_ChatCommandsTeller_AllChannelWelcomeMessage{RBX_LOCALIZATION_DEFAULT}Chat '/?' or '/help' for a list of chat commands.",
                             ["eDestroyed"] = Event,
                             ["eMessagePosted"] = Event,
                             ["eSpeakerJoined"] = Event,
                             ["eSpeakerLeft"] = Event,
                             ["eSpeakerMuted"] = Event,
                             ["eSpeakerUnmuted"] = Event
                          },
                          ["system"] =  ▼  {
                             ["AutoJoin"] = true,
                             ["ChatHistory"] = {},
                             ["ChatService"] = "*** cycle table reference detected ***",
                             ["Destroyed"] = Signal Event,
                             ["FilterMessageFunctions"] =  ▼  {
                                ["FunctionMap"] = {},
                                ["RegisteredFunctions"] = {},
                                ["RegisteredPriorites"] = {}
                             },
                             ["HistoryIndex"] = 0,
                             ["Joinable"] = true,
                             ["Leavable"] = false,
                             ["MaxHistory"] = 200,
                             ["MessagePosted"] = Signal Event,
                             ["Mutes"] = {},
                             ["Name"] = "System",
                             ["Private"] = false,
                             ["ProcessCommandsFunctions"] =  ▼  {
                                ["FunctionMap"] =  ▼  {
                                   [20] =  ▼  {
                                      ["default_commands"] = "function"
                                   }
                                },
                                ["RegisteredFunctions"] =  ▼  {
                                   ["default_commands"] = 20
                                },
                                ["RegisteredPriorites"] =  ▼  {
                                   [1] = 20
                                }
                             },
                             ["SpeakerJoined"] = Signal Event,
                             ["SpeakerLeft"] = Signal Event,
                             ["SpeakerMuted"] = Signal Event,
                             ["SpeakerUnmuted"] = Signal Event,
                             ["Speakers"] = {},
                             ["WelcomeMessage"] = "{RBX_LOCALIZATION_KEY}GameChat_ChatServiceRunner_SystemChannelWelcomeMessage{RBX_LOCALIZATION_DEFAULT}This channel is for system and game notifications.",
                             ["eDestroyed"] = Event,
                             ["eMessagePosted"] = Event,
                             ["eSpeakerJoined"] = Event,
                             ["eSpeakerLeft"] = Event,
                             ["eSpeakerMuted"] = Event,
                             ["eSpeakerUnmuted"] = Event
                          },
                          ["team"] =  ▼  {
                             ["AutoJoin"] = false,
                             ["ChatHistory"] = {},
                             ["ChatService"] = "*** cycle table reference detected ***",
                             ["Destroyed"] = Signal Event,
                             ["FilterMessageFunctions"] =  ▼  {
                                ["FunctionMap"] = {},
                                ["RegisteredFunctions"] = {},
                                ["RegisteredPriorites"] = {}
                             },
                             ["HistoryIndex"] = 0,
                             ["Joinable"] = false,
                             ["Leavable"] = false,
                             ["MaxHistory"] = 200,
                             ["MessagePosted"] = Signal Event,
                             ["Mutes"] = {},
                             ["Name"] = "Team",
                             ["Private"] = true,
                             ["ProcessCommandsFunctions"] =  ▼  {
                                ["FunctionMap"] =  ▼  {
                                   [0] =  ▼  {
                                      ["replication_function"] = "function"
                                   },
                                   [20] =  ▼  {
                                      ["default_commands"] = "function"
                                   }
                                },
                                ["RegisteredFunctions"] =  ▼  {
                                   ["default_commands"] = 20,
                                   ["replication_function"] = 0
                                },
                                ["RegisteredPriorites"] =  ▼  {
                                   [1] = 20,
                                   [2] = 0
                                }
                             },
                             ["SpeakerJoined"] = Signal Event,
                             ["SpeakerLeft"] = Signal Event,
                             ["SpeakerMuted"] = Signal Event,
                             ["SpeakerUnmuted"] = Signal Event,
                             ["Speakers"] = {},
                             ["WelcomeMessage"] = "{RBX_LOCALIZATION_KEY}GameChat_TeamChat_WelcomeMessage{RBX_LOCALIZATION_DEFAULT}This is a private channel between you and your team members.",
                             ["eDestroyed"] = Event,
                             ["eMessagePosted"] = Event,
                             ["eSpeakerJoined"] = Event,
                             ["eSpeakerLeft"] = Event,
                             ["eSpeakerMuted"] = Event,
                             ["eSpeakerUnmuted"] = Event
                          }
                       },
                       ["ChatServiceMajorVersion"] = 0,
                       ["ChatServiceMinorVersion"] = 5,
                       ["FilterMessageFunctions"] =  ▼  {
                          ["FunctionMap"] = {},
                          ["RegisteredFunctions"] = {},
                          ["RegisteredPriorites"] = {}
                       },
                       ["MessageIdCounter"] = 0,
                       ["ProcessCommandsFunctions"] =  ▼  {
                          ["FunctionMap"] =  ▼  {
                             [0] =  ▼  {
                                ["flood_detection"] = "function"
                             },
                             [10] =  ▼  {
                                ["chat_commands_inquiry"] = "function",
                                ["default_commands"] = "function",
                                ["mute_commands"] = "function",
                                ["team_commands"] = "function",
                                ["whisper_commands"] = "function"
                             },
                             [25] =  ▼  {
                                ["message_validation"] = "function"
                             }
                          },
                          ["RegisteredFunctions"] =  ▼  {
                             ["chat_commands_inquiry"] = 10,
                             ["default_commands"] = 10,
                             ["flood_detection"] = 0,
                             ["message_validation"] = 25,
                             ["mute_commands"] = 10,
                             ["team_commands"] = 10,
                             ["whisper_commands"] = 10
                          },
                          ["RegisteredPriorites"] =  ▼  {
                             [1] = 25,
                             [2] = 10,
                             [3] = 0
                          }
                       },
                       ["SpeakerAdded"] = Signal Event,
                       ["SpeakerRemoved"] = Signal Event,
                       ["Speakers"] = {},
                       ["eChannelAdded"] = Event,
                       ["eChannelRemoved"] = Event,
                       ["eSpeakerAdded"] = Event,
                       ["eSpeakerRemoved"] = Event
                    },
                    ["ExtraData"] = {},
                    ["GetSpeaker"] = "function",
                    ["MutedSpeakers"] = {},
                    ["Name"] = "ServerTest"
                 }  -  Server - ServerSpeaker:17

Instead of speaker.new(), use ChatService:AddSpeaker()
It is documented on dev hub in Lua Chat System

1 Like

I must have skipped over that, I tried looking for :CreateSpeaker() but wasn’t able to find it because it was replaced (or I’m misremembering) with :AddSpeaker() :man_facepalming:

Thanks for that!