Skip to content

Commit 7a9a163

Browse files
update Open Source Docs from Roblox internal teams
1 parent 977557e commit 7a9a163

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+493
-288
lines changed

content/en-us/characters/pathfinding.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,14 @@ local path = PathfindingService:CreatePath({
131131
This section uses the following pathfinding script for the player's character. To test while reading:
132132

133133
1. Copy the code into a `Class.LocalScript` within `Class.StarterCharacterScripts`.
134-
1. Edit line 11 to a `Datatype.Vector3` destination that the player character can reach.
134+
1. Set the `TEST_DESTINATION` variable to a `Datatype.Vector3` destination in your 3D world that the player character can reach.
135135
1. Proceed through the following sections to learn about path computation and character movement.
136136

137137
```lua title='LocalScript - Character Pathfinding' highlight='11'
138138
local PathfindingService = game:GetService("PathfindingService")
139139
local Players = game:GetService("Players")
140140
local RunService = game:GetService("RunService")
141+
local Workspace = game:GetService("Workspace")
141142

142143
local path = PathfindingService:CreatePath()
143144

@@ -206,6 +207,7 @@ After you've created a valid path with `Class.PathfindingService:CreatePath()|Cr
206207
local PathfindingService = game:GetService("PathfindingService")
207208
local Players = game:GetService("Players")
208209
local RunService = game:GetService("RunService")
210+
local Workspace = game:GetService("Workspace")
209211

210212
local path = PathfindingService:CreatePath()
211213

@@ -238,6 +240,7 @@ Once the `Class.Path` is computed, it will contain a series of **waypoints** tha
238240
local PathfindingService = game:GetService("PathfindingService")
239241
local Players = game:GetService("Players")
240242
local RunService = game:GetService("RunService")
243+
local Workspace = game:GetService("Workspace")
241244

242245
local path = PathfindingService:CreatePath()
243246

@@ -279,6 +282,7 @@ Each waypoint consists of both a **position** (`Datatype.Vector3`) and **action*
279282
local PathfindingService = game:GetService("PathfindingService")
280283
local Players = game:GetService("Players")
281284
local RunService = game:GetService("RunService")
285+
local Workspace = game:GetService("Workspace")
282286

283287
local path = PathfindingService:CreatePath()
284288

@@ -344,13 +348,14 @@ end
344348
Many Roblox worlds are dynamic; parts might move or fall and floors may collapse. This can block a computed path and prevent the character from reaching its destination. To handle this, you can connect the `Class.Path.Blocked` event and re-compute the path around whatever blocked it.
345349

346350
<Alert severity="warning">
347-
Paths may also become blocked somewhere **behind** the agent, such as a pile of rubble falling on a path as the agent runs away, but that doesn't mean the agent should stop moving. The conditional statement on line&nbsp;31 makes sure that the path is re-computed only if the blocked waypoint is **ahead** of the current waypoint.
351+
Paths may also become blocked somewhere **behind** the agent, such as a pile of rubble falling on a path as the agent runs away, but that doesn't mean the agent should stop moving. The <Typography noWrap>`if blockedWaypointIndex >= nextWaypointIndex`</Typography> check makes sure that the path is re-computed only if the blocked waypoint is **ahead** of the current waypoint.
348352
</Alert>
349353

350354
```lua title='LocalScript - Character Pathfinding' highlight='16, 29-37'
351355
local PathfindingService = game:GetService("PathfindingService")
352356
local Players = game:GetService("Players")
353357
local RunService = game:GetService("RunService")
358+
local Workspace = game:GetService("Workspace")
354359

355360
local path = PathfindingService:CreatePath()
356361

@@ -411,6 +416,7 @@ Keys in the `Costs` table should be string names representing `Enum.Material` na
411416
local PathfindingService = game:GetService("PathfindingService")
412417
local Players = game:GetService("Players")
413418
local RunService = game:GetService("RunService")
419+
local Workspace = game:GetService("Workspace")
414420

415421
local path = PathfindingService:CreatePath({
416422
Costs = {
@@ -441,6 +447,7 @@ In some cases, [material preference](#set-material-costs) is not enough. For exa
441447
local PathfindingService = game:GetService("PathfindingService")
442448
local Players = game:GetService("Players")
443449
local RunService = game:GetService("RunService")
450+
local Workspace = game:GetService("Workspace")
444451

445452
local path = PathfindingService:CreatePath({
446453
Costs = {
@@ -498,6 +505,7 @@ To create a `Class.PathfindingLink` using this example:
498505
local PathfindingService = game:GetService("PathfindingService")
499506
local Players = game:GetService("Players")
500507
local RunService = game:GetService("RunService")
508+
local Workspace = game:GetService("Workspace")
501509

502510
local path = PathfindingService:CreatePath({
503511
Costs = {
@@ -513,6 +521,7 @@ To create a `Class.PathfindingLink` using this example:
513521
local PathfindingService = game:GetService("PathfindingService")
514522
local Players = game:GetService("Players")
515523
local RunService = game:GetService("RunService")
524+
local Workspace = game:GetService("Workspace")
516525

517526
local path = PathfindingService:CreatePath({
518527
Costs = {
@@ -582,7 +591,7 @@ To create a `Class.PathfindingLink` using this example:
582591
end
583592

584593
function useBoat()
585-
local boat = workspace.BoatModel
594+
local boat = Workspace.BoatModel
586595

587596
humanoid.Seated:Connect(function()
588597
-- Start boat moving if agent is seated

content/en-us/characters/r6-to-r15-adapter.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ The adapter parts perform the following:
2727

2828
## Enable the R6 to R15 Adapter
2929

30-
You can enable the R6 to R15 Adapter by setting the `Class.Workspace.AvatarUnificationMode` property in Workspace. You can only access this property if **Avatar Type** is set to `R6` in your **Game Settings**. At this time, the **Default** setting disables the `Class.Workspace.AvatarUnificationMode|AvatarUnificationMode`.
30+
You can enable the R6 to R15 Adapter by setting the `Class.Workspace.AvatarUnificationMode|AvatarUnificationMode` property in `Class.Workspace`. You can only access this property if **Avatar Type** is set to `R6` in your **Game Settings**. At this time, the **Default** setting disables unification mode.
3131

3232
To enable the R6 to R15 Adapter:
3333

34-
1. In the Explorer, navigate to **Workspace**.
35-
2. In the Properties window, set **AvatarUnificationMode** to **Enabled**.
34+
1. In the **Explorer**, navigate to **Workspace**.
35+
2. In the **Properties** window, set **AvatarUnificationMode** to **Enabled**.
3636

3737
## Known limitations
3838

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,9 @@ Display chat bubbles for non-player characters (NPCs) by calling `Class.TextChat
449449

450450
```lua
451451
local TextChatService = game:GetService("TextChatService")
452+
local Workspace = game:GetService("Workspace")
452453

453-
local prompt = workspace.SomeNPC.ProximityPrompt
454+
local prompt = Workspace.SomeNPC.ProximityPrompt
454455
local head = prompt.Parent:WaitForChild("Head")
455456

456457
prompt.Triggered:Connect(function()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ You can also stylize non-player dialogue and add [chat bubbles](../chat/bubble-c
591591

592592
```lua title='Client Script'
593593
local TextChatService = game:GetService("TextChatService")
594+
local Workspace = game:GetService("Workspace")
594595

595596
local generalChannel: TextChannel = TextChatService:WaitForChild("TextChannels").RBXGeneral
596597

@@ -604,7 +605,7 @@ TextChatService.OnIncomingMessage = function(textChatMessage: TextChatMessage)
604605
properties.PrefixText = string.format("<font color='#%s'>%s: </font>", "#50C999", textChatMessage.Metadata)
605606

606607
-- Add bubble chat
607-
TextChatService:DisplayBubble(workspace.Statue, textChatMessage.Text)
608+
TextChatService:DisplayBubble(Workspace.Statue, textChatMessage.Text)
608609
end
609610

610611
return properties

content/en-us/chat/legacy/legacy-chat-system.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,13 @@ Command functions are often used to implement [Admin Commands](../../chat/legacy
140140
In this example a **ChatModule** is used to create a `Class.Part` if a user types `/part` in the chat. Note that this function returns true if a part was created which will stop the message from proceeding and no message will be displayed. If a part is not created, this function needs to return false so that the message can continue working through the system.
141141

142142
```lua
143+
local Workspace = game:GetService("Workspace")
144+
143145
local function Run(ChatService)
144146
local function createPart(speakerName, message, channelName)
145147
if string.sub(message, 1, 5) == "/part" then
146148
local newPart = Instance.new("Part")
147-
newPart.Parent = workspace
149+
newPart.Parent = Workspace
148150
return true
149151
end
150152
return false

content/en-us/luau/enums.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ print(Enum.PartType.Cylinder.EnumType) -- PartType
4444
To assign an `Datatype.EnumItem` as the value of a property, use the full `Datatype.Enum` declaration. You can also use its `Value` or `EnumType`.
4545

4646
```lua
47+
local Workspace = game:GetService("Workspace")
48+
4749
local part = Instance.new("Part") -- Create a new part
4850
part.Shape = Enum.PartType.Cylinder -- By EnumItem (best practice)
4951
part.Shape = Enum.PartType.Cylinder.Value -- By EnumItem Value
5052
part.Shape = 2 -- By EnumItem Value
5153
part.Shape = Enum.PartType.Cylinder.Name -- By EnumItem Name
5254
part.Shape = "Cylinder" -- By EnumItem Name
5355

54-
part.Parent = workspace
56+
part.Parent = Workspace
5557
```

content/en-us/luau/functions.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,18 @@ Methods are functions that are members of an object, such as a [class](/referenc
7878
All objects in Roblox descend from `Class.Instance` and have commonly used methods including `Class.Instance:Destroy()`, `Class.Instance:Clone()`, and `Class.Instance:FindFirstChild()`.
7979

8080
```lua
81-
-- Destroying a Part with dot notation (function)
81+
local Workspace = game:GetService("Workspace")
82+
83+
-- Destroying a part with dot notation (function)
8284
local firstPart = Instance.new("Part")
83-
firstPart.Parent = workspace
85+
firstPart.Parent = Workspace
8486
print(firstPart.Parent) -- Workspace
8587
firstPart.Destroy(firstPart)
8688
print(firstPart.Parent) -- nil
8789

88-
-- Destroying a Part with colon notation (method)
90+
-- Destroying a part with colon notation (method)
8991
local secondPart = Instance.new("Part")
90-
secondPart.Parent = workspace
92+
secondPart.Parent = Workspace
9193
print(secondPart.Parent) -- Workspace
9294
secondPart:Destroy()
9395
print(secondPart.Parent) -- nil

content/en-us/luau/nil.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@ print(dictionaryTable.Tuesday) -- nil
2929
You can use `nil` to clear some properties of objects. For example, you can set the `Parent` of an object to `nil` to effectively remove the object from the experience. To return the object to the experience after you remove it, reassign the `Parent`. The following example demonstrates how to use `nil` to remove a `Class.Part`:
3030

3131
```lua
32+
local Workspace = game:GetService("Workspace")
33+
3234
-- Create a new brick
3335
local part = Instance.new("Part")
34-
-- Parent new Part to the workspace, making it viewable
35-
part.Parent = workspace
36+
-- Parent new part to the workspace, making it viewable
37+
part.Parent = Workspace
3638
task.wait(1)
37-
-- Remove the Part from view, but not from memory
39+
-- Remove the part from view but not from memory
3840
part.Parent = nil
3941
task.wait(1)
40-
-- Part still exists because it's referenced by the variable 'part', so it can be returned to view
41-
part.Parent = workspace
42+
-- Part still exists because it's referenced by the variable "part", so it can be returned to view
43+
part.Parent = Workspace
4244
task.wait(1)
4345
-- Remove the part from view again
4446
part.Parent = nil

content/en-us/luau/tables.md

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ To create an array using a Luau table, declare the values in sequential order, s
2525

2626
```lua
2727
-- Construct an array with three items
28-
local testArray = {"A string", 3.14159, workspace.Camera}
28+
local testArray = {"A string", 3.14159, true}
2929
print(testArray)
3030
```
3131

@@ -35,23 +35,23 @@ To read from an array, add a pair of square brackets after its reference and spe
3535

3636
```lua
3737
-- Construct an array with three items
38-
local testArray = {"A string", 3.14159, workspace.Camera}
38+
local testArray = {"A string", 3.14159, true}
3939

4040
print(testArray[1]) -- A string
4141
print(testArray[2]) -- 3.14159
42-
print(testArray[3]) -- Camera
42+
print(testArray[3]) -- true
4343
```
4444

4545
<Alert severity="warning">
46-
Unlike some languages, Luau uses 1-based indexing for arrays, so the first item in the array is <InlineCode>[1]</InlineCode>, not <InlineCode>[0]</InlineCode>.
46+
Unlike some languages, Luau uses 1-based indexing for arrays, so the first item in the array is `[1]`, not `[0]`.
4747
</Alert>
4848

4949
### Write to arrays
5050

5151
To define or rewrite the value of an array at an index, declare the index number in square brackets (`[index]`) followed by `=` and the value:
5252

5353
```lua
54-
local testArray = {"A string", 3.14159, workspace.Camera}
54+
local testArray = {"A string", 3.14159, true}
5555

5656
testArray[2] = 12345
5757
testArray[4] = "New string"
@@ -62,10 +62,10 @@ print(testArray[4]) -- New string
6262

6363
### Iterate over arrays
6464

65-
To iterate over an array, you can use a `for` loop. Because the arrays have numerical indices, you can also use a numeric `for` loop from **1** to the length of the array (`#array`).
65+
To iterate over an array, you can use a `for` loop. Because the arrays have numerical indices, you can also use a numeric `for` loop from `1` to the length of the array (`#array`).
6666

6767
```lua
68-
local testArray = {"A string", 3.14159, workspace.Camera, "New string"}
68+
local testArray = {"A string", 3.14159, true, "New string"}
6969

7070
-- Loop using general iteration
7171
for index, value in testArray do
@@ -76,17 +76,6 @@ end
7676
for index = 1, #testArray do
7777
print(index, testArray[index])
7878
end
79-
80-
--[[ Resulting output:
81-
1 A string
82-
2 3.14159
83-
3 Camera
84-
4 New string
85-
1 A string
86-
2 3.14159
87-
3 Camera
88-
4 New string
89-
]]
9079
```
9180

9281
### Insert items

content/en-us/luau/type-coercion.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,22 @@ Some properties expect certain data types, such as an [Enum](#enums) or string,
3838
Luau coerces numbers and strings of enum values into the full enum name. For example, you can name the value of the `Class.Part.Material` property using a number, string, or full enum name, and the `print()` function always prints the full enum name. It's best practice to be explicit and use the full enum name. For more information on Enums, see [Enums](./enums.md).
3939

4040
```lua
41+
local Workspace = game:GetService("Workspace")
42+
4143
local part1 = Instance.new("Part")
4244
part1.Material = 816
43-
part1.Parent = workspace
45+
part1.Parent = Workspace
4446
print(part1.Material) -- Enum.Material.Concrete
4547

4648
local part2 = Instance.new("Part")
4749
part2.Material = "Concrete"
48-
part2.Parent = workspace
50+
part2.Parent = Workspace
4951
print(part2.Material) -- Enum.Material.Concrete
5052

5153
-- This is best practice because it's the most explicit
5254
local part3 = Instance.new("Part")
5355
part3.Material = Enum.Material.Concrete
54-
part3.Parent = workspace
56+
part3.Parent = Workspace
5557
print(part3.Material) -- Enum.Material.Concrete
5658
```
5759

0 commit comments

Comments
 (0)