Client-Side Chat Modules

You can use the following chat modules to support client-side behaviors of the Legacy Chat System.

ChatWindow

The ChatWindow is the main chat module of the Legacy Chat System's client side.

Methods

AddChannel

RemoveChannel

  • Parameters: string: channelName
  • Description: Removes a ChatChannelUI with the given channelName from the window.
  • Returns: void

GetChannel

GetCurrentChannel

SwitchCurrentChannel

  • Parameters: string: channelName
  • Description: Switches the current channel to the ChatChannelUI with the given channelName if it exists.
  • Returns: void

GetVisible

  • Parameters: None
  • Description: Returns whether the window is visible or not. Note: this refers to the chat UI in general; when the chat window fades to transparent due to inactivity, the window is still considered visible.
  • Returns: bool

SetVisible

  • Parameters: bool: visible
  • Description: Sets the visibility of the chat window.
  • Returns: void

FadeOutBackground

  • Parameters: float: duration
  • Description: Fades out the background over the given duration in seconds. Note: later calls to control fading in/out will override earlier calls.
  • Returns: void

FadeInBackground

  • Parameters: float: duration
  • Description: Fades in the background over the given duration in seconds. Note: later calls to control fading in/out will override earlier calls.
  • Returns: void

FadeOutText

  • Parameters: float: duration
  • Description: Fades out the text over the given duration in seconds. Note: later calls to control fading in/out will override earlier calls.
  • Returns: void

FadeInText

  • Parameters: float: duration
  • Description: Fades in the text over the given duration in seconds. Note: later calls to control fading in/out will override earlier calls.
  • Returns: void

ChatBar

The ChatBar handles client-side text entry for the Lua Chat System. There are two key components of the ChatBar:

  • ChatBar , a TextBox , where the player inputs messages and commands (highlighted in orange)
  • MessageMode , a TextLabel , which can display information about the message being sent (highlighted in green)

Methods

GetTextBox

  • Parameters: None
  • Description: Returns the TextBox of the chat bar.
  • Returns: TextBox

GetMessageModeTextLabel

  • Parameters: None
  • Description: Returns the MessageMode TextLabel.
  • Returns: TextLabel

IsFocused

  • Parameters: None
  • Description: Returns whether the chat bar's TextBox is in focus (player is typing in box). Equivalent to calling TextBox:IsFocused on the result of GetTextBox.
  • Returns: bool

CaptureFocus

  • Parameters: None
  • Description: Forces the client to focus on the TextBox of the chat bar. Equivalent to calling TextBox:CaptureFocus on the result of GetTextBox.
  • Returns: void

ReleaseFocus

  • Parameters: bool: submitted = false
  • Description: Releases the focus of the chat bar TextBox. If submitted is true, this will behave as if the player pressed Enter to submit the message.
  • Returns: void

ResetText

  • Parameters: None
  • Description: Sets the Text of the chat bar TextBox to the empty string.
  • Returns: void

SetTextBoxText

  • Parameters: string: text
  • Description: Sets the Text of the chat bar TextBox to the given text.
  • Returns: void

GetTextBoxText

  • Parameters: None
  • Description: Returns the text in the chat bar TextBox.Text.
  • Returns: string

SetTextLabelText

  • Parameters: string: text
  • Description: Sets the Text of the MessageMode TextLabel to the given text.
  • Returns: void

GetEnabled

  • Parameters: None
  • Description: Returns whether the chat bar is Visible.
  • Returns: bool

SetEnabled

  • Parameters: bool: enabled
  • Description: Sets whether the chat bar is Visible.
  • Returns: void

SetTextSize

  • Parameters: int: textSize
  • Description: Sets the TextSize of both the chat bar's TextBox and MessageMode TextLabel.
  • Returns: void

ResetSize

  • Parameters: None
  • Description: Resets the size of the chat bar to one line of text.
  • Returns: void

SetChannelTarget

  • Parameters: string: channelName
  • Description: Sets the target ChatChannelUI given its channelName to which the chat bar should submit messages.
  • Returns: void

FadeOutBackground

  • Parameters: float: duration duration
  • Description: Fades out the background over the given duration in seconds. Note: later calls to control fading in/out will override earlier calls.
  • Returns: void

FadeInBackground

  • Parameters: float: duration duration
  • Description: Fades in the background over the given duration in seconds. Note: later calls to control fading in/out will override earlier calls.
  • Returns: void

FadeOutText

  • Parameters: float: duration duration
  • Description: Fades out the text over the given duration in seconds. Note: later calls to control fading in/out will override earlier calls.
  • Returns: void

FadeInText

  • Parameters: float: duration duration
  • Description: Fades in the text over the given duration in seconds. Note: later calls to control fading in/out will override earlier calls.
  • Returns: void

ChatChannelUI

The ChatChannelUI is the client-side version of ChatChannel. It receives ChatMessages from the server and passes them on to the ChatMessageLogDisplay. associated with it.

Methods

AddMessageToChannel

RemoveLastMessageFromChannel

ClearMessageLog

ChatMessageLogDisplay

The ChatMessageLogDisplay manages the rendering of ChatMessages in a ChatChannelUI.

Methods

AddMessage

  • Parameters: ChatMessage message
  • Description: Adds a message to the message log display.
  • Returns: void

RemoveLastMessage

  • Parameters: None
  • Description: Removes the oldest ChatMessage in the message log display.
  • Returns: void

ReorderAllMessages

  • Parameters: None
  • Description: Re-sorts all of the message displays in ascending order, relative to the size of the message display. This should be called if the message log display is resized.
  • Returns: void

Clear

  • Parameters: None
  • Description: Removes all ChatMessages from the message log display.
  • Returns: void

FadeOutText

  • Parameters: float duration
  • Description: Fades out the text over the given duration in seconds. Note: later calls to control fading in/out will override earlier calls.
  • Returns: void

FadeInText

  • Parameters: float duration
  • Description: Fades in the text over the given duration in seconds. Note: later calls to control fading in/out will override earlier calls.
  • Returns: void

ChatCustomState

The ChatCustomState is an interface of callbacks used when creating a custom chat state in the chat bar.

Whisper chat and team chat use ChatCustomState to indicate to the player where their message will be sent.

Callbacks

TextUpdated

  • Parameters: None
  • Description: Called when the text in the chat bar is updated.
  • Returns: void

GetMessage

  • Parameters: None
  • Description: Called in order to retrieve the text of the message as it would be written as a single command. This is used in the case that the server needs to process the command as text, rather than the visualized state of the command.
  • Returns: string

ProcessCompletedMessage

  • Parameters: None
  • Description: Called when the player submits the message that is being processed by the custom state. This should return true if the message should not be displayed or sent to the server.
  • Returns: bool

Destroy

  • Parameters: None
  • Description: Called as the ChatBar is being reset back to its original state prior to the custom state modification.
  • Returns: void

ChatSettings

The ChatSettings is a dictionary of settings for the client-side of the Lua Chat System. They are stored in a ModuleScript named ChatSettings , which can be found inside of the Chat game service, under the Folder named ClientChatModules . The module may be required and its properties can be changed during run-time.

To change a setting, require this module using a LocalScript in the following manner:


-- Require the ChatSettings module (wait for it to load)
local Chat = game:GetService("Chat")
local ClientChatModules = Chat:WaitForChild("ClientChatModules")
local ChatSettings = require(ClientChatModules:WaitForChild("ChatSettings"))
-- Change settings like you would with any other table.
ChatSettings.MaximumMessageLength = 100

Chat Behavior Settings

WindowDraggable

  • Type: bool
  • Default: false
  • Description: Determines whether the ChatWindow is Draggable.

WindowResizable

  • Type: bool
  • Default: false
  • Description: Determines whether the ChatWindow can be resized by the player

GamepadNavigationEnabled

  • Type: bool
  • Default: false
  • Description: Determines whether gamepads can navigate chat UI.

ShowUserOwnFilteredMessage

  • Type: bool
  • Default: true
  • Description: Determines whether players should see the filtered version of their chat messages, or the original content they typed in.

ChatOnWithTopBarOff

  • Type: bool
  • Default: false
  • Description: Determines whether the chat UI is enabled even if the topbar is disabled.

BubbleChatEnabled

  • Type: bool
  • Default: game:GetService("Players").BubbleChat
  • Description: Determines whether bubble chat is enabled.

ClassicChatEnabled

  • Type: bool
  • Default: game:GetService("Players").ClassicChat
  • Description: Determines whether classic chat is enabled.

Chat Text Size Settings

ChatWindowTextSize

  • Type: int
  • Default: 18
  • Description: Determines the size of the text in the ChatWindow.

ChatBarTextSize

  • Type: int
  • Default: 18
  • Description: Determines the size of the text in the ChatBar.

ChatWindowTextSizePhone

  • Type: int
  • Default: 14
  • Description: Determines the size of the text in the ChatWindow for phones.

ChatBarTextSizePhone

  • Type: int
  • Default: 14
  • Description: Determines the size of the text in the ChatBar for phones.

Font Settings

DefaultFont

ChatBarFont

Color Settings

BackGroundColor

  • Type: Color3
  • Default: Color3.new(0, 0, 0)
  • Description: Determines the BackgroundColor3 of the ChatWindow.

DefaultMessageColor

DefaultNameColor

  • Type: Color3
  • Default: Color3.new(1, 1, 1)
  • Description: Determines the default TextColor3 of speaker names of ChatMessagesin the ChatWindow.

ChatBarBackGroundColor

  • Type: Color3
  • Default: Color3.new(0, 0, 0)
  • Description: Determines the BackgroundColor3 of the ChatBar.

ChatBarBoxColor

  • Type: Color3
  • Default: Color3.new(1, 1, 1)
  • Description: Determines the BackgroundColor3 of the ChatBar TextBox.

ChatBarTextColor

  • Type: Color3
  • Default: Color3.new(0, 0, 0)
  • Description: Determines the TextColor3 of the ChatBar.

ErrorMessageTextColor

  • Type: Color3
  • Default: Color3.fromRGB(245, 50, 50)
  • Description: Determines the TextColor3 of error messages.

Window Settings

MinimumWindowSize

  • Type: UDim2
  • Default: UDim2.new(0.3, 0, 0.25, 0)
  • Description: Determines the smallest possible size of the ChatWindow (given that WindowResizable is enabled).

MaximumWindowSize

  • Type: UDim2
  • Default: UDim2.new(1, 0, 1, 0)
  • Description: Determines the largest possible size of the ChatWindow (given that WindowResizable is enabled).
  • Notes: If this is changed to be greater than the full screen size, strange things start to happen with size/position bounds checking.

DefaultWindowPosition

  • Type: UDim2
  • Default: UDim2.new(0, 0, 0, 0)
  • Description: Determines the default position of the ChatWindow.

DefaultWindowSizePhone

  • Type: UDim2
  • Default: UDim2.new(0.5, 0, 0.5, (7 * 2) + (5 * 2))
  • Description: Determines the default size of the ChatWindow on phones.

DefaultWindowSizeTablet

  • Type: UDim2
  • Default: UDim2.new(0.4, 0, 0.3, (7 * 2) + (5 * 2))
  • Description: Determines the default size of the ChatWindow on tables.

DefaultWindowSizeDesktop

  • Type: UDim2
  • Default: UDim2.new(0.3, 0, 0.25, (7 * 2) + (5 * 2))
  • Description: Determines the default size of the ChatWindow on desktop.

Fade Out and In Settings

ChatWindowBackgroundFadeOutTime

  • Type: float (seconds)
  • Default: 0.5
  • Description: Determines how long fading out the ChatWindow background should take.

ChatWindowTextFadeOutTime

  • Type: float (seconds)
  • Default: 30
  • Description: Determines how long fading out the ChatWindow text should take.

ChatDefaultFadeDuration

  • Type: float (seconds)
  • Default: 0.8
  • Description: Determines how long fading out chat UI elements should take.

ChatShouldFadeInFromNewInformation

  • Type: bool
  • Default: false
  • Description: Determines whether the chat should fade in when receiving new messages.

ChatAnimationFPS

  • Type: float
  • Default: 20.0
  • Description: Determines the framerate of fading animations in the chat UI.

Channel Settings

GeneralChannelName

  • Type: string
  • Default: "All"
  • Description: Determines the name of the default channel.

EchoMessagesInGeneralChannel

  • Type: bool
  • Default: true
  • Description: Determines whether messages to channels other than the default channel ought to be echoed into the default channel.

MaxChannelNameLength

  • Type: int
  • Default: 12
  • Description: Determines the maximum length of a channel name before it is truncated.

MessageHistoryLengthPerChannel

  • Type: int
  • Default: 50
  • Description: Determines the maximum number of ChatMessage that can be displayed in a chat channel.

ShowJoinAndLeaveHelpText

  • Type: bool
  • Default: false
  • Description: Determines whether the help text for joining/leaving channels is shown.

Message Settings

MaximumMessageLength

  • Type: int
  • Default: 200
  • Description: Determines the maximum length of ChatMessages.

DisallowedWhiteSpace

  • Type: array<string>
  • Default: {"\n", "\r", "\t", "\v", "\f"}
  • Description: Determines the whitespace characters that are disallowed.

ClickOnPlayerNameToWhisper

  • Type: bool
  • Default: true
  • Description: Determines whether the player can click on another player's name to engage in a whisper chat with them.

ClickOnChannelNameToSetMainChannel

  • Type: bool
  • Default: true
  • Description: Determines whether the player can click on a channel's tab to set it as their main channel.

Miscellaneous Settings

WhisperCommandAutoCompletePlayerNames

  • Type: bool
  • Default: true
  • Description: Determines whether the whisper command should auto-complete player names.

Events

SettingsChanged

  • Parameters: string settingName , Variant newValue
  • Description: Fires when a setting with the given settingName is changed to newValue.