defineTextChat
defineTextChat<
Channels>(options?):TextChatSettings<Channels>
Declares a game’s text chat: its channels and who receives a message.
Export it from src/game.ts and re-export it from the room’s scene file
beside the game, as export { game, room, textChat } from "../game". A
game that exports none gets one all channel. The room decides every
message: its sender, the sender’s right to send, the channel, the
limits, the filter and each recipient; a game shapes who receives one,
never what it says. defineRoom({ textChat: false }) turns chat off. As
Roblox’s TextChatService, whose channels and delivery
callback these are.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Channels extends Record<string, TextChannel> |
object |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
TextChatOptions<Channels> |
Returns
Section titled “Returns”TextChatSettings<Channels>
Example
Section titled “Example”export const textChat = defineTextChat({ channels: { all: textChannel(), team: teamTextChannel() }, // Ghosts receive everyone; the living never receive ghosts. canReceive: (world, sender, recipient) => !isGhost(world, sender) || isGhost(world, recipient),});