Skip to content

Commit 2d6ddf2

Browse files
update Open Source Docs from Roblox internal teams
1 parent cccc79f commit 2d6ddf2

File tree

12 files changed

+235
-281
lines changed

12 files changed

+235
-281
lines changed

content/common/navigation/engine/guides.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ navigation:
419419
section:
420420
- title: Overview
421421
path: /chat/in-experience-text-chat
422-
- title: Guidelies
422+
- title: Guidelines
423423
path: /chat/guidelines
424424
- title: Chat window
425425
path: /chat/chat-window
@@ -428,14 +428,14 @@ navigation:
428428
- title: Examples
429429
path: /chat/examples/simple-custom-frontend-ui
430430
section:
431-
- title: Custom UI
432-
path: /chat/examples/simple-custom-frontend-ui
433431
#- title: Custom System Messages
434432
# path: /chat/examples/custom-system-messages
435433
- title: Chat tags
436434
path: /chat/examples/group-chat-tags
437435
- title: Proximity chat
438436
path: /chat/examples/proximity-chat
437+
- title: Custom UI
438+
path: /chat/examples/simple-custom-frontend-ui
439439
- title: Custom chat commands
440440
path: /chat/examples/custom-text-chat-commands
441441
- title: Legacy chat system

content/common/navigation/scale/analytics.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ navigation:
2020
path: /production/analytics/acquisition
2121
- title: Audience
2222
path: /production/analytics/audience
23+
- title: Feedback
24+
path: /production/analytics/feedback
2325
- title: Monetization
2426
path: /production/analytics/monetization
2527

content/en-us/assets/players/in-experience-text-chat/TextChat-Example1.png

Lines changed: 0 additions & 3 deletions
This file was deleted.

content/en-us/assets/players/in-experience-text-chat/TextChat-Example2.png

Lines changed: 0 additions & 3 deletions
This file was deleted.

content/en-us/chat/chat-window.md

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ Appearance of the **channel tabs** is customizable through `Class.ChannelTabsCon
285285

286286
## Customize messages
287287

288-
You can customize the appearance of chat message bodies and prefixes using `Class.ChatWindowMessageProperties` and `Class.TextChatService.OnChatWindowAdded` callbacks without overriding the existing UI. The customization options let you modify the appearance of chat messages to match your experience's theme, and you can also sort or highlight messages from different user groups by adding chat tags and coloring prefixes.
288+
You can customize the appearance of chat message bodies and prefixes using `Class.ChatWindowMessageProperties` and `Class.TextChatService.OnChatWindowAdded` callbacks without overriding the existing UI. The customization options let you modify the appearance of chat messages to match your experience's theme, and you can also sort or highlight messages from different user groups by coloring prefixes or adding [chat tags](./examples/group-chat-tags.md).
289289

290290
<Alert severity="info">
291291
`Class.ChatWindowMessageProperties` and `Class.TextChatService.OnChatWindowAdded|OnChatWindowAdded` only affect the appearance of messages in the chat window. To customize chat bubbles, see [Bubble Chat](../chat/bubble-chat.md).
@@ -354,35 +354,6 @@ TextChatService.OnChatWindowAdded = function(message: TextChatMessage)
354354
end
355355
```
356356

357-
### Add chat tags
358-
359-
If your experience has users with special [attributes](../studio/properties.md#instance-attributes) like VIP status, you can attach chat tags wrapped in brackets to the front of user messages to highlight their messages. The following `Class.LocalScript` in `Class.StarterPlayerScripts` examines all `Class.Player` instances representing users in your experience and appends VIP chat tags to those with the `IsVIP` attribute.
360-
361-
<img src="../assets/players/in-experience-text-chat/Chat-Tag-VIP.png" width="780" alt="VIP chat tag appended to user name in the chat window." />
362-
363-
```lua title="Appending Chat Tags"
364-
local TextChatService = game:GetService("TextChatService")
365-
local Players = game:GetService("Players")
366-
367-
local chatWindowConfiguration = TextChatService.ChatWindowConfiguration
368-
369-
TextChatService.OnChatWindowAdded = function(message: TextChatMessage)
370-
local properties = chatWindowConfiguration:DeriveNewMessageProperties()
371-
372-
if message.TextSource then
373-
local player = Players:GetPlayerByUserId(message.TextSource.UserId)
374-
if player:GetAttribute("IsVIP") then
375-
properties.PrefixText = "[VIP] " .. message.PrefixText
376-
377-
properties.PrefixTextProperties = chatWindowConfiguration:DeriveNewMessageProperties()
378-
properties.PrefixTextProperties.TextColor3 = Color3.fromRGB(255, 125, 50)
379-
end
380-
end
381-
382-
return properties
383-
end
384-
```
385-
386357
### Rich text customization
387358

388359
Rich text [font color tags](../ui/rich-text.md#supported-tags) can be used to format chat messages, helpful if you want to apply formatting to very specific parts of the message. Note that rich text does not support gradients, but the following code sample shows how you can move the user name (stored in `Class.TextChatMessage.PrefixText`) into the message body and then apply rich text tagging to only the name portion.
@@ -444,7 +415,7 @@ For a more detailed guide on how to customize the appearance of system messages,
444415

445416
#### Default system messages
446417

447-
When `Class.TextChatService.CreateDefaultTextChannels` is true, one of the default text channels is the RBXSystem channel. The default chat scripts automatically display system messages in this channel. You can customize the appearance of these messages using the `Class.TextChannel.OnIncomingMessage` callback.
418+
When `Class.TextChatService.CreateDefaultTextChannels` is `true`, one of the default text channels is the `RBXSystem` channel. The default chat scripts automatically display system messages in this channel. You can customize the appearance of these messages using the `Class.TextChannel.OnIncomingMessage` callback.
448419

449420
You might want to customize or alter the system messages that are automatically emitted by the chat system. Since the default system messages are localized for users, you should reference them by `TextChatMessage.Metadata` in your [text chat callbacks](../chat/in-experience-text-chat.md#text-chat-hooks-and-callbacks) if you wish to customize their appearance.
450421

content/en-us/chat/examples/custom-text-chat-commands.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,53 @@ title: Custom text chat commands
33
description: Learn how to create custom chat commands.
44
---
55

6-
`Class.TextChatService` has built-in chat commands for common purposes, such as muting other players and using avatar emotes. You can enable them by setting `Class.TextChatService.CreateDefaultCommands` to true in the Studio properties panel.
6+
`Class.TextChatService` has built-in chat commands for common purposes, such as muting other players and using avatar emotes. You can enable them by setting `Class.TextChatService.CreateDefaultCommands|CreateDefaultCommands` to `true` in Studio's **Properties** window.
77

88
You can also add custom commands using `Class.TextChatCommand`. Users sending a defined command in the chat input bar trigger a callback defined by `Class.TextChatCommand.Triggered` to perform your customized actions.
99

1010
The following example shows how to create a chat command that allows players to increase or decrease their character's size when they input `/super` or `/mini`.
1111

1212
1. Add a `Class.TextChatCommand` instance inside `Class.TextChatService`.
13-
2. Rename it SizeCommand.
13+
2. Rename it to **SizeCommand**.
1414

1515
<img src="../../assets/studio/explorer/TextChatService-TextChatCommand.png" width="320" />
1616

17-
3. Set its PrimaryAlias property to `/super` and its SecondaryAlias to `/mini`.
17+
3. Set its `Class.TextChatCommand.PrimaryAlias|PrimaryAlias` property to `/super` and its `Class.TextChatCommand.SecondaryAlias|SecondaryAlias` to `/mini`.
1818

1919
<img src="../../assets/players/in-experience-text-chat/TextChatCommand-Aliases.png" width="320" />
2020

2121
4. Insert the following `Class.Script` inside `Class.ServerScriptService` to define a callback for the chat command that scales the character's size:
2222

23-
```lua title="Script" highlight="4,6"
24-
local TextChatService = game:GetService("TextChatService")
25-
local Players = game:GetService("Players")
26-
27-
local sizeCommand: TextChatCommand = TextChatService:WaitForChild("SizeCommand")
28-
29-
sizeCommand.Triggered:Connect(function(textSource, message)
30-
local scaleMult = 1
31-
local messageWords = string.split(message, " ")
32-
if messageWords[1] == "/super" then
33-
scaleMult = 2
34-
elseif messageWords[1] == "/mini" then
35-
scaleMult = 0.5
36-
end
37-
38-
local player = Players:GetPlayerByUserId(textSource.UserId)
39-
if player then
40-
local character = player.Character
41-
if character then
42-
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
43-
if humanoid then
44-
for _, child in humanoid:GetChildren() do
45-
if child:IsA("NumberValue") then
46-
child.Value *= scaleMult
47-
end
48-
end
49-
end
50-
end
51-
end
52-
end)
53-
```
23+
```lua title="Script" highlight="4,6"
24+
local TextChatService = game:GetService("TextChatService")
25+
local Players = game:GetService("Players")
26+
27+
local sizeCommand: TextChatCommand = TextChatService:WaitForChild("SizeCommand")
28+
29+
sizeCommand.Triggered:Connect(function(textSource, message)
30+
local scaleMult = 1
31+
local messageWords = string.split(message, " ")
32+
if messageWords[1] == "/super" then
33+
scaleMult = 2
34+
elseif messageWords[1] == "/mini" then
35+
scaleMult = 0.5
36+
end
37+
38+
local player = Players:GetPlayerByUserId(textSource.UserId)
39+
if player then
40+
local character = player.Character
41+
if character then
42+
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
43+
if humanoid then
44+
for _, child in humanoid:GetChildren() do
45+
if child:IsA("NumberValue") then
46+
child.Value *= scaleMult
47+
end
48+
end
49+
end
50+
end
51+
end
52+
end)
53+
```
5454

5555
<video controls src="../../assets/players/in-experience-text-chat/Text-Custom-Command.mp4" width="90%"></video>
Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,56 @@
11
---
2-
title: Assign chat tags by group membership
3-
description: Example of how to assign chat tags to players based on their membership of a group.
2+
title: Assign chat tags
3+
description: Example of how to assign chat tags to players based on their membership in a group.
44
---
55

6-
This example demonstrates how to assign chat tags to players based on their membership of a group. Chat tags are a way to visually identify a player in the chat window and useful for indicating a player's role, status, or group membership.
6+
This example demonstrates how to assign **chat tags** to players based on their membership in a [group](../../projects/groups.md). Chat tags are a way to visually identify a player in the chat window and useful for indicating a player's role or status.
77

8-
First, create a script in ServerScriptService, and add the following code to it:
8+
<img src="../../assets/players/in-experience-text-chat/Chat-Tag-VIP.png" width="780" alt="VIP chat tag appended to user name in the chat window." />
99

10-
```lua title="Server"
11-
local Players = game:GetService("Players")
10+
Because [text chat callbacks](../in-experience-text-chat.md#text-chat-hooks-and-callbacks) expect a non-yielding callback, attempting to query the group membership status of a player in the `Class.TextChatService.OnIncomingMessage` callback is not recommended, as it may cause the chat system to hang or become unresponsive.
1211

13-
-- Replace 123456 with the Group ID you want to check for
14-
local groupId = 123456
12+
Instead, set a player [attribute](../../studio/properties.md#instance-attributes) when they join the server. Setting an attribute lets you reuse the player's status in other parts of your experience such as allowing access to particular areas or providing bonus experience.
1513

16-
Players.PlayerAdded:Connect(function(player)
17-
local success, isInGroup = pcall(function()
18-
return player:IsInGroup(groupId)
19-
end)
14+
1. Create a `Class.Script` in `Class.ServerScriptService` and add the following code to it:
2015

21-
if success and isInGroup then
22-
player:SetAttribute("isFanClubMember", true)
23-
else
24-
player:SetAttribute("isFanClubMember", false)
25-
end
26-
end)
27-
```
16+
```lua title="Server"
17+
local Players = game:GetService("Players")
2818

29-
Because [Text Chat callbacks](../in-experience-text-chat.md#text-chat-hooks-and-callbacks) expect a non-yielding callback, attempting to query the group membership status of a player in the `TextChatService.OnIncomingMessage` callback is not recommended, as it may cause the chat system to hang or become unresponsive.
19+
-- Replace 123456 with the group ID you want to check for
20+
local groupID = 123456
3021

31-
Instead, set a player attribute when they join the server. Setting an attribute lets you reuse this information in other parts of your experience. For example, in addition to setting chat tag, you might use it to allow access to particular areas or provide bonus experience.
22+
Players.PlayerAdded:Connect(function(player)
23+
local success, isInGroup = pcall(function()
24+
return player:IsInGroup(groupID)
25+
end)
3226

33-
Then create a `LocalScript` in **StartCharacterScripts**, and add the following code to it to display a **\[Fan\]** tag in the chat window:
27+
if success and isInGroup then
28+
player:SetAttribute("IsVIP", true)
29+
else
30+
player:SetAttribute("IsVIP", false)
31+
end
32+
end)
33+
```
3434

35-
```lua title="Client"
36-
local Players = game:GetService("Players")
37-
local TextChatService = game:GetService("TextChatService")
35+
2. Create a `Class.LocalScript` in `Class.StarterPlayer``Class.StarterCharacterScripts` and add the following code to display a **\[VIP\]** tag in the chat window:
3836

37+
```lua title="Client"
38+
local Players = game:GetService("Players")
39+
local TextChatService = game:GetService("TextChatService")
3940

40-
TextChatService.OnIncomingMessage = function(message: TextChatMessage)
41-
local textSource = message.TextSource
42-
if textSource then
43-
local player = Players:GetPlayerByUserId(textSource.UserId)
44-
if player then
45-
local isFanClubMember = player:GetAttribute("isFanClubMember")
46-
if isFanClubMember == true then
47-
local overrideProperties = Instance.new("TextChatMessageProperties")
48-
overrideProperties.PrefixText = `[Fan] {message.PrefixText}`
49-
return overrideProperties
50-
end
51-
end
52-
end
41+
TextChatService.OnIncomingMessage = function(message: TextChatMessage)
42+
local textSource = message.TextSource
43+
if textSource then
44+
local player = Players:GetPlayerByUserId(textSource.UserId)
45+
if player then
46+
if player:GetAttribute("IsVIP") == true then
47+
local overrideProperties = Instance.new("TextChatMessageProperties")
48+
overrideProperties.PrefixText = "[VIP] " .. message.PrefixText
49+
return overrideProperties
50+
end
51+
end
52+
end
5353

54-
return nil
55-
end
56-
```
57-
58-
![Chat window showing the Fan tag.](../../assets/players/in-experience-text-chat/TextChat-Group-Tag.png)
54+
return nil
55+
end
56+
```

content/en-us/chat/examples/proximity-chat.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,42 @@ title: Proximity-based chat
33
description: Learn how to implement exclusive chat for users who are close to each other in locations using the TextChatService.
44
---
55

6-
This example shows how to implement an exclusive chat for users who are near each other in the game world. It extends the callback with a function using `Class.TextSource` to identify the locations of a user who might be a potential message receiver. If this function returns false, it means that the user locates further than the preset valid range from the message sender, so the system doesn't deliver the message to that user. Add the following to a `Class.Script` in ServerScriptStorage:
6+
This example shows how to implement an exclusive chat for users who are near each other in the game world. It extends the callback with a function using `Class.TextSource` to identify the locations of a user who might be a potential message receiver. If this function returns `false`, it means that the user locates further than the preset valid range from the message sender, so the system doesn't deliver the message to that user.
7+
8+
Add the following to a `Class.Script` in `Class.ServerScriptService`:
79

810
```lua title="Server"
9-
-- Get the text chat and players services
1011
local TextChatService = game:GetService("TextChatService")
1112
local Players = game:GetService("Players")
1213

13-
-- Get the chat channel for proximity-based chat.
14-
-- This example uses the general channel. You can replace this with a dedicated channel.
14+
-- Get the chat channel for proximity-based chat
15+
-- You can replace this general channel with a dedicated channel
1516
local generalChannel: TextChannel = TextChatService:WaitForChild("TextChannels").RBXGeneral
1617

17-
-- Define a function to get the position of a user's character.
18+
-- Function to get the position of a user's character
1819
local function getPositionFromUserId(userId: number)
19-
-- Get the player associated with the given userId.
20-
local targetPlayer = Players:GetPlayerByUserId(userId)
21-
22-
-- If the player exists, get their character's position.
23-
if targetPlayer then
24-
local targetCharacter = targetPlayer.Character
25-
if targetCharacter then
26-
return targetCharacter:GetPivot().Position
27-
end
28-
end
29-
30-
-- Return a default position if the player or character cannot be found.
31-
return Vector3.zero
20+
-- Get the player associated with the given user ID
21+
local targetPlayer = Players:GetPlayerByUserId(userId)
22+
23+
-- If the player exists, get their character's position
24+
if targetPlayer then
25+
local targetCharacter = targetPlayer.Character
26+
if targetCharacter then
27+
return targetCharacter:GetPivot().Position
28+
end
29+
end
30+
31+
-- Return a default position if the player or character cannot be found
32+
return Vector3.zero
3233
end
3334

34-
-- Set the ShouldDeliverCallback for the general channel to control message delivery.
35+
-- Set the callback for the general channel to control message delivery
3536
generalChannel.ShouldDeliverCallback = function(textChatMessage: TextChatMessage, targetTextSource: TextSource)
36-
-- Get the positions of the message sender and target.
37-
local sourcePos = getPositionFromUserId(textChatMessage.TextSource.UserId)
38-
local targetPos = getPositionFromUserId(targetTextSource.UserId)
37+
-- Get the positions of the message sender and target
38+
local sourcePos = getPositionFromUserId(textChatMessage.TextSource.UserId)
39+
local targetPos = getPositionFromUserId(targetTextSource.UserId)
3940

40-
-- If the distance between the sender and target is less than 50 units, deliver the message.
41-
return (targetPos - sourcePos).Magnitude < 50
41+
-- Deliver message if distance between sender and target is less than 50 units
42+
return (targetPos - sourcePos).Magnitude < 50
4243
end
4344
```

0 commit comments

Comments
 (0)