Display System Message In Chat

am just trying to do a script where it will display system messages in chat but it keeps giving error.

local msg = "My Message"
local TextService = game:GetService("TextChatService") 

game.Players.PlayerAdded:Wait()
wait(5)
TextService.Channels.RBXGeneral:DisplaySystemMessage(msg)

error:
Channels is not a valid member of TextChatService “TextChatService”

2 Likes

Is this script local or server sided as I believe you can only do this on the client.

TextService.TextChannels instead of TextService.Channels. You should be fine without a WaitForChild here because of the wait statement, but yeah it’s TextChannels not Channels.

If this is LegacyChatService you need to use a different method:

game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
    Text = "Text",
    Color = Color3.fromRGB(255, 255, 255),
    Font = Enum.Font.Michroma,
    FontSize = Enum.FontSize.Size24
})

This must be a LocalScript under one of the following:

  • ReplicatedFirst
  • StarterGui
  • StarterPack
  • StarterPlayerScripts
  • StarterCharacterScripts
2 Likes

The error is self explanatory. The folder under TextChatService where the channels are located is called TextChannels, not Channels.

So you’d need to do this instead:

local generalChannel: TextChannel = TextService:WaitForChild("TextChannels").RBXGeneral

generalChannel:DisplaySystemMessage(msg)

WaitForChild would need to be used here since the TextChannels folder will appear at runtime. They aren’t already there prior to runtime. Note that the DisplaySystemMessage method can only be called in a Local Script.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.