Chat
Houses the Lua code responsible for running the legacy chat system.
Memory category | Instances |
---|
Member index 18
Removed member index 1
History | Member | |
---|---|---|
267 | SetIsLuaChatBackendOverwritten(value: bool): void |
Description
The Chat service houses the Lua code responsible for running the legacy chat system. Similar to StarterPlayerScripts, default objects like Scripts and ModuleScripts are inserted into the service.
History 55
- 573 Change ReturnType of SetBubbleChatSettings from void to null
- 573 Change ReturnType of RegisterChatCallback from void to null
- 573 Change ReturnType of ChatLocal from void to null
- 573 Change ReturnType of Chat from void to null
- 553 Add
- 553 Add
- 553 Add
- 553 Change PreferredDescriptor of FilterStringForPlayerAsync from to FilterStringAsync
- 553 Change Default of LoadDefaultChat from to true
- 553 Change Default of BubbleChatEnabled from to false
- 486 Change ThreadSafety of LoadDefaultChat from ReadOnly to ReadSafe
- 486 Change ThreadSafety of BubbleChatEnabled from ReadOnly to ReadSafe
- 484 Change Parameters of FilterStringForPlayerAsync from (stringToFilter: string, playerToFilterFor: Instance) to (stringToFilter: string, playerToFilterFor: Player)
- 484 Change Parameters of FilterStringForBroadcast from (stringToFilter: string, playerFrom: Instance) to (stringToFilter: string, playerFrom: Player)
- 484 Change Parameters of FilterStringAsync from (stringToFilter: string, playerFrom: Instance, playerTo: Instance) to (stringToFilter: string, playerFrom: Player, playerTo: Player)
- 462 Change ThreadSafety of Chatted from to Unsafe
- 462 Change ThreadSafety of BubbleChatSettingsChanged from to Unsafe
- 462 Change ThreadSafety of SetBubbleChatSettings from to Unsafe
- 462 Change ThreadSafety of RegisterChatCallback from to Unsafe
- 462 Change ThreadSafety of InvokeChatCallback from to Unsafe
- 462 Change ThreadSafety of GetShouldUseLuaChat from to Unsafe
- 462 Change ThreadSafety of FilterStringForPlayerAsync from to Unsafe
- 462 Change ThreadSafety of FilterStringForBroadcast from to Unsafe
- 462 Change ThreadSafety of FilterStringAsync from to Unsafe
- 462 Change ThreadSafety of ChatLocal from to Unsafe
- 462 Change ThreadSafety of Chat from to Unsafe
- 462 Change ThreadSafety of CanUsersChatAsync from to Unsafe
- 462 Change ThreadSafety of CanUserChatAsync from to Unsafe
- 462 Change ThreadSafety of LoadDefaultChat from to ReadOnly
- 462 Change ThreadSafety of BubbleChatEnabled from to ReadOnly
- 451 Add BubbleChatSettingsChanged
- 451 Add SetBubbleChatSettings
- 363 Add BubbleChatEnabled
- 355 Add RegisterChatCallback
- 355 Add InvokeChatCallback
- 323 Change Parameters of CanUsersChatAsync from (userIdFrom: int, userIdTo: int) to (userIdFrom: int64, userIdTo: int64)
- 323 Change Parameters of CanUserChatAsync from (userId: int) to (userId: int64)
- 281 Add ChatLocal
- 279 Add CanUsersChatAsync
- 279 Add CanUserChatAsync
- 275 Add LoadDefaultChat
- 267 Remove SetIsLuaChatBackendOverwritten
- 264 Add SetIsLuaChatBackendOverwritten
- 256 Add GetShouldUseLuaChat
- 247 Change Tags of FilterStringForPlayerAsync from [Yields] to [Yields, Deprecated]
- 247 Add FilterStringForBroadcast
- 246 Change Tags of FilterStringForPlayerAsync from [Yields, Deprecated] to [Yields]
- 246 Remove FilterStringForBroadcast
- 247 Change Tags of FilterStringForPlayerAsync from [Yields] to [Yields, Deprecated]
- 247 Add FilterStringForBroadcast
- 242 Add FilterStringAsync
- 174 Add FilterStringForPlayerAsync
- 47 Add Chatted
- 47 Add Chat
- 47 Add Chat
Members 18
BubbleChatEnabled
Type | Default | |
---|---|---|
bool | false |
If true, entering a message in the chat will result in a chat bubble popping up above the player's Player.Character. This behavior can either be enabled by directly ticking this checkbox in Studio, or by using a LocalScript:
1 2 |
|
This must be done on the client, toggling this value in a server-side Script will have no effect.
Thread safety | ReadSafe |
---|---|
Category | Behavior |
Loaded/Saved | true |
History 4
- 553 Change Default of BubbleChatEnabled from to false
- 486 Change ThreadSafety of BubbleChatEnabled from ReadOnly to ReadSafe
- 462 Change ThreadSafety of BubbleChatEnabled from to ReadOnly
- 363 Add BubbleChatEnabled
BubbleChatSettingsChanged
Parameters (1) | |
---|---|
settings | Variant |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 2
- 462 Change ThreadSafety of BubbleChatSettingsChanged from to Unsafe
- 451 Add BubbleChatSettingsChanged
CanUserChatAsync
Parameters (1) | ||
---|---|---|
userId | int64 | |
Returns (1) | ||
bool |
Will return false if the player with the specified Player.UserId is not allowed to chat because of their account settings.
Thread safety | Unsafe |
---|
History 3
- 462 Change ThreadSafety of CanUserChatAsync from to Unsafe
- 323 Change Parameters of CanUserChatAsync from (userId: int) to (userId: int64)
- 279 Add CanUserChatAsync
CanUsersChatAsync
Parameters (2) | ||
---|---|---|
userIdFrom | int64 | |
userIdTo | int64 | |
Returns (1) | ||
bool |
Will return false if the two users cannot communicate because their account settings do not allow it.
Thread safety | Unsafe |
---|
History 3
- 462 Change ThreadSafety of CanUsersChatAsync from to Unsafe
- 323 Change Parameters of CanUsersChatAsync from (userIdFrom: int, userIdTo: int) to (userIdFrom: int64, userIdTo: int64)
- 279 Add CanUsersChatAsync
Chat
Parameters (3) | Default | |
---|---|---|
partOrCharacter | Instance | |
color | ChatColor | Blue |
Returns (1) | ||
null |
The Chat function fires the Chat.Chatted event with the parameters specified in this method.
By default, there is a LocalScript inside of each player's PlayerScripts object named BubbleChat, which causes a dialog-like billboard to appear above the partOrCharacter when the chatted event is fired.
Note: Since dialogs are controlled by a LocalScript, you will not be able to see any dialogs created from this method unless you are running in Play Solo mode.
Thread safety | Unsafe |
---|
ChatLocal
Parameters (3) | Default | |
---|---|---|
partOrCharacter | Instance | |
color | ChatColor | Blue |
Returns (1) | ||
null |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
Chatted
Parameters (3) | |
---|---|
part | Instance |
color | ChatColor |
Fires when Chat:Chat() is called.
Thread safety | Unsafe |
---|
FilterStringAsync
Parameters (3) | ||
---|---|---|
stringToFilter | string | |
playerFrom | Player | |
playerTo | Player | |
Returns (1) | ||
string |
Partial Deprecation Warning: Calling this function from the client using a LocalScript is deprecated, and will be disabled in the future. Text filtering should be done from a Script on the server using the similarly-named TextService:FilterStringAsync(), which uses a different set of parameters and return type.
Games that do not properly filter player-generated text might be subject to moderation action. Please be sure a game properly filters text before publishing it.
FilterStringAsync filters a string using filtering that is appropriate for the sending and receiving player. If the filtered string is to be used for a persistent message, such as the name of a shop, writing on a plaque, etc, then the function should be called with the author as both the sender and receiver.
This function should be used every time a player can enter custom text in any context, most commonly using a TextBox. Some examples of text to be filtered:
- Custom chat messages
- Custom character names
- Names for a shop in a tycoon-style game
Thread safety | Unsafe |
---|
History 3
- 484 Change Parameters of FilterStringAsync from (stringToFilter: string, playerFrom: Instance, playerTo: Instance) to (stringToFilter: string, playerFrom: Player, playerTo: Player)
- 462 Change ThreadSafety of FilterStringAsync from to Unsafe
- 242 Add FilterStringAsync
FilterStringForBroadcast
Parameters (2) | ||
---|---|---|
stringToFilter | string | |
playerFrom | Player | |
Returns (1) | ||
string |
Filters a string sent from playerFrom for broadcast to no particular target. The filtered message has more restrictions than Chat:FilterStringAsync().
Some examples of where this method could be used:
- Message walls
- Cross-server shouts
- User-created signs
Calling FilterString from LocalScripts is deprecated and will be disabled in the future. Text filtering should be done from server-side Scripts using FilterStringAsync.
Note: A game not using this filter function for custom chat or other user generated text may be subjected to moderation action.
Thread safety | Unsafe |
---|
History 5
- 484 Change Parameters of FilterStringForBroadcast from (stringToFilter: string, playerFrom: Instance) to (stringToFilter: string, playerFrom: Player)
- 462 Change ThreadSafety of FilterStringForBroadcast from to Unsafe
- 247 Add FilterStringForBroadcast
- 246 Remove FilterStringForBroadcast
- 247 Add FilterStringForBroadcast
FilterStringForPlayerAsync
Parameters (2) | ||
---|---|---|
stringToFilter | string | |
playerToFilterFor | Player | |
Returns (1) | ||
string |
The FilterStringForPlayerAsync function filters a string appropriate to the given player's age settings, so they see what is appropriate to them. This function will only work if called from a Script on the server. If called on a client it will fail.
Thread safety | Unsafe |
---|
History 7
- 553 Change PreferredDescriptor of FilterStringForPlayerAsync from to FilterStringAsync
- 484 Change Parameters of FilterStringForPlayerAsync from (stringToFilter: string, playerToFilterFor: Instance) to (stringToFilter: string, playerToFilterFor: Player)
- 462 Change ThreadSafety of FilterStringForPlayerAsync from to Unsafe
- 247 Change Tags of FilterStringForPlayerAsync from [Yields] to [Yields, Deprecated]
- 246 Change Tags of FilterStringForPlayerAsync from [Yields, Deprecated] to [Yields]
- 247 Change Tags of FilterStringForPlayerAsync from [Yields] to [Yields, Deprecated]
- 174 Add FilterStringForPlayerAsync
GetShouldUseLuaChat
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
bool |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 2
- 462 Change ThreadSafety of GetShouldUseLuaChat from to Unsafe
- 256 Add GetShouldUseLuaChat
InvokeChatCallback
Parameters (2) | ||
---|---|---|
callbackType | ChatCallbackType | |
callbackArguments | Tuple | |
Returns (1) | ||
Tuple |
InvokeChatCallback will call a function registered by RegisterChatCallback, given the ChatCallbackType enum and the arguments to send the function. It will return the result of the registered function, or raise an error if no function has been registered.
This function is called by the Lua Chat System so that chat callbacks may be registered to change the behavior of certain features. Unless you are replacing the default Lua Chat System with your own, you should not need to call this function. You can read about the different callback functions at Chat:RegisterChatCallback().
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of InvokeChatCallback from to Unsafe
- 355 Add InvokeChatCallback
LoadDefaultChat
Type | Default | |
---|---|---|
bool | true |
Toggles whether the default chat framework should be automatically loaded when the game runs.
Write security | NotAccessibleSecurity |
---|---|
Thread safety | ReadSafe |
Category | Behavior |
Loaded/Saved | true |
History 4
- 553 Change Default of LoadDefaultChat from to true
- 486 Change ThreadSafety of LoadDefaultChat from ReadOnly to ReadSafe
- 462 Change ThreadSafety of LoadDefaultChat from to ReadOnly
- 275 Add LoadDefaultChat
RegisterChatCallback
Parameters (2) | ||
---|---|---|
callbackType | ChatCallbackType | |
callbackFunction | Function | |
Returns (1) | ||
null |
RegisterChatCallback binds a function to some chat system event in order to affect the behavior of the Lua chat system. The first argument determines the event (using the ChatCallbackType enum) to which the second argument, the function, shall be bound. The default Lua chat system uses InvokeChatCallback to invoke registered functions. Attempting to register a server- or client- only callback on a peer that isn't a server or client respectively will raise an error. The following sections describe in what ways registered functions will be used.
OnCreatingChatWindow
Client-only. Invoked before the client constructs the chat window. Must return a table of settings to be merged into the information returned by the ChatSettings module.
OnClientFormattingMessage
Client-only. Invoked before the client displays a message (whether it is a
player chat message, system message, or /me command). This function is
invoked with the message object and may (or may not) return a table to be
merged into message.ExtraData
.
OnClientSendingMessage
Not invoked at this time.
OnServerReceivingMessage
Server-only. Invoked when the server receives a message from a speaker (note that speakers may not necessarily be a Player chatting). This callback is called with the Message object. The function can make changes to the Message object to change the manner in which the message is processed. The Message object must be returned for this callback to do anything. Setting this callback can allow the server to, for example:
- Set
message.ShouldDeliver
to false in order to cancel delivery of the message to players (useful for implementing a chat exclusion list) - Get/set the speaker's name color (
message.ExtraData.NameColor
, a Color3) on a message-by-message basis
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of RegisterChatCallback from void to null
- 462 Change ThreadSafety of RegisterChatCallback from to Unsafe
- 355 Add RegisterChatCallback
SetBubbleChatSettings
Parameters (1) | ||
---|---|---|
settings | Variant | |
Returns (1) | ||
null |
This function customizes various settings of the in-game bubble chat.
Before using this, make sure that bubble chat is enabled by setting Chat.BubbleChatEnabled to true.
The settings argument is a table where the keys are the names of the settings you want to edit and the values are what you want to change these settings to. Note that you don't have to include all of them in the settings argument, omitting some will result in them keeping their default value.
This function is client-side only, attempting to call it on the server will trigger an error.
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of SetBubbleChatSettings from void to null
- 462 Change ThreadSafety of SetBubbleChatSettings from to Unsafe
- 451 Add SetBubbleChatSettings