Skip to content

Commit 40c1fac

Browse files
author
ramdoys
authored
fix: updates code practices across the board (#938)
## Changes Changes some code examples to better fit good practices. ## Checks By submitting your pull request for review, you agree to the following: - [x] This contribution was created in whole or in part by me, and I have the right to submit it under the terms of this repository's open source licenses. - [x] I understand and agree that this contribution and a record of it are public, maintained indefinitely, and may be redistributed under the terms of this repository's open source licenses. - [x] To the best of my knowledge, all proposed changes are accurate. ---------
1 parent 8452aac commit 40c1fac

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,9 @@ TextChatService.OnBubbleAdded = function(message: TextChatMessage, adornee: Inst
424424
-- Add a UIGradient as a child to customize the gradient
425425
local uiGradient : UIGradient = Instance.new("UIGradient")
426426
uiGradient.Color = ColorSequence.new(Color3.fromRGB(110, 4, 0), Color3.fromRGB(0, 0, 0))
427-
uiGradient.Parent = bubbleProperties
428427
uiGradient.Rotation = 90
429-
428+
uiGradient.Parent = bubbleProperties
429+
430430
return bubbleProperties
431431
end
432432
end

content/en-us/education/build-it-play-it-mansion-of-wonder/adding-scripts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ The three scripts below will look for the particle emitter and beam objects crea
239239
playerBeam = beamTemplate:Clone()
240240
playerBeam.Attachment0 = playerBeamAttachment
241241
playerBeam.Attachment1 = targetBeamAttachment
242-
playerBeam.Parent = humanoidRootPart
243242
playerBeam.Enabled = true
243+
playerBeam.Parent = humanoidRootPart
244244
end
245245

246246
local function setupPlayer()

content/en-us/luau/enums.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ To assign an `Datatype.EnumItem` as the value of a property, use the full `Datat
4545

4646
```lua
4747
local part = Instance.new("Part") -- Create a new part
48-
part.Parent = workspace
49-
5048
part.Shape = Enum.PartType.Cylinder -- By EnumItem (best practice)
5149
part.Shape = Enum.PartType.Cylinder.Value -- By EnumItem Value
5250
part.Shape = 2 -- By EnumItem Value
5351
part.Shape = Enum.PartType.Cylinder.Name -- By EnumItem Name
5452
part.Shape = "Cylinder" -- By EnumItem Name
53+
54+
part.Parent = workspace
5555
```

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@ Luau coerces numbers and strings of enum values into the full enum name. For exa
3939

4040
```lua
4141
local part1 = Instance.new("Part")
42-
part1.Parent = workspace
4342
part1.Material = 816
43+
part1.Parent = workspace
4444
print(part1.Material) -- Enum.Material.Concrete
4545

4646
local part2 = Instance.new("Part")
47-
part2.Parent = workspace
4847
part2.Material = "Concrete"
48+
part2.Parent = workspace
4949
print(part2.Material) -- Enum.Material.Concrete
5050

5151
-- This is best practice because it's the most explicit
5252
local part3 = Instance.new("Part")
53-
part3.Parent = workspace
5453
part3.Material = Enum.Material.Concrete
54+
part3.Parent = workspace
5555
print(part3.Material) -- Enum.Material.Concrete
5656
```
5757

content/en-us/performance-optimization/identifying.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ game.Loaded:Connect(function()
131131
local loadTime = os.clock() - startTime
132132
local roundedLoadTime = math.round(loadTime * 10000) / 10000 -- four decimal places
133133
print("Game loaded in " .. roundedLoadTime .. " seconds.")
134-
print("Number of instances loaded: " .. #game.Workspace:GetDescendants())
134+
print("Number of instances loaded: " .. #workspace:GetDescendants())
135135
end)
136136
```
137137

content/en-us/reference/engine/classes/Instance.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ properties:
178178
-- Create a part and parent it to the workspace
179179
local part = Instance.new("Part")
180180
part.Parent = workspace
181-
-- Instance new can also take Parent as a second parameter
181+
-- Instance new can also take Parent as a second parameter, though it is not recommended
182182
Instance.new("NumberValue", workspace)
183183
```
184184

content/en-us/reference/engine/classes/WeldConstraint.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ properties:
138138
partB.Parent = workspace
139139
140140
local weld = Instance.new("WeldConstraint")
141-
weld.Parent = partA
142141
weld.Part0 = partA
143142
weld.Part1 = partB
143+
weld.Parent = partA
144144
```
145145
code_samples:
146146
type: BasePart
@@ -175,15 +175,15 @@ properties:
175175
local partB = Instance.new("Part")
176176
177177
partA.Position = Vector3.new(0, 10, 0)
178-
partA.Parent = game.Workspace
178+
partA.Parent = workspace
179179
180180
partB.Position = Vector3.new(0, 10, 10)
181-
partB.Parent = game.Workspace
181+
partB.Parent = workspace
182182
183183
local weld = Instance.new("WeldConstraint")
184-
weld.Parent = partA
185184
weld.Part0 = partA
186185
weld.Part1 = partB
186+
weld.Parent = partA
187187
```
188188
code_samples:
189189
type: BasePart

content/en-us/ui/frames.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ If you want a 3D object such as a `Class.BasePart` to rotate on its own within t
119119
-- Viewport camera initialization
120120
local viewportCamera = Instance.new("Camera")
121121
viewportCamera.FieldOfView = cameraFieldOfView
122-
viewportCamera.Parent = viewportFrame
123122
viewportFrame.CurrentCamera = viewportCamera
123+
viewportCamera.Parent = viewportFrame
124124

125125
-- Viewport object initialization
126126
local object = viewportFrame:FindFirstChildWhichIsA("BasePart")

0 commit comments

Comments
 (0)