Skip to content

Commit 6164280

Browse files
author
ramdoys
authored
fix: Update game.Players to game:GetService("Players") (#954)
## Changes Updates `game.Players` to `game:GetService("Players")`. ## 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 54a88cc commit 6164280

File tree

6 files changed

+23
-9
lines changed

6 files changed

+23
-9
lines changed

content/en-us/production/monetization/developer-products.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ You can also combine functions inside a `Class.LocalScript|LocalScript`. For exa
113113

114114
```lua
115115
local MarketplaceService = game:GetService("MarketplaceService")
116-
local player = game.Players.LocalPlayer
116+
local Players = game:GetService("Players")
117+
118+
local player = Players.LocalPlayer
117119
local button = script.Parent
118120

119121
-- Replace the placeholder ID with your developer product ID

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ description: |
2929
The Backpack can be accessed from both the client and the server.
3030
3131
```lua
32+
local Players = game:GetService("Players")
33+
3234
-- Accessing Backpack from a Server Script:
33-
game.Players.PlayerName.Backpack
35+
local backpack = Players.PlayerName.Backpack
3436
3537
-- Accessing Backpack from a LocalScript:
36-
game.Players.LocalPlayer.Backpack
38+
local backpack = Players.LocalPlayer.Backpack
3739
```
3840
code_samples:
3941
- Backpack-Give-Tool

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,11 +1417,14 @@ events:
14171417
of the user's mouse relative to a GUI element:
14181418
14191419
```lua
1420+
local Players = game:GetService("Players")
1421+
14201422
local CustomScrollingFrame = script.Parent
14211423
local SubFrame = CustomScrollingFrame:FindFirstChild("SubFrame")
14221424
1423-
local mouse = game.Players.LocalPlayer:GetMouse()
1424-
function getPosition(X, Y)
1425+
local mouse = Players.LocalPlayer:GetMouse()
1426+
1427+
local function getPosition(X, Y)
14251428
local gui_X = CustomScrollingFrame.AbsolutePosition.X
14261429
local gui_Y = CustomScrollingFrame.AbsolutePosition.Y
14271430

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ methods:
155155
`Datatype.BrickColor` property:
156156
157157
```lua
158+
local Players = game:GetService("Players")
159+
158160
local function paintFigure(character, color)
159161
-- Iterate over the child objects of the character
160162
for _, child in character:GetChildren() do
@@ -165,7 +167,7 @@ methods:
165167
end
166168
end
167169
end
168-
paintFigure(game.Players.Player.Character, BrickColor.new("Bright blue"))
170+
paintFigure(Players.Player.Character, BrickColor.new("Bright blue"))
169171
```
170172
171173
Since all classes inherit from `Class.Object`, calling

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,11 @@ events:
391391
player clicks while the created tool is equipped.
392392
393393
```lua
394+
local Players = game:GetService("Players")
395+
394396
local tool = Instance.new("Tool")
395397
tool.RequiresHandle = false
396-
tool.Parent = game.Players.LocalPlayer.Backpack
398+
tool.Parent = Players.LocalPlayer.Backpack
397399
398400
function onActivation()
399401
print("Tool activated")
@@ -423,9 +425,11 @@ events:
423425
player releases their click while the tool is equipped and activated.
424426
425427
```lua
428+
local Players = game:GetService("Players")
429+
426430
local tool = Instance.new("Tool")
427431
tool.RequiresHandle = false
428-
tool.Parent = game.Players.LocalPlayer.Backpack
432+
tool.Parent = Players.LocalPlayer.Backpack
429433
430434
function toolDeactivated()
431435
print("Tool deactivated")

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,11 @@ methods:
209209
text as the second argument:
210210
211211
```lua
212+
local Players = game:GetService("Players")
212213
local LocalizationService = game:GetService("LocalizationService")
213214
214215
local success, translator = pcall(function()
215-
return LocalizationService:GetTranslatorForPlayerAsync(game.Players.LocalPlayer)
216+
return LocalizationService:GetTranslatorForPlayerAsync(Players.LocalPlayer)
216217
end)
217218
218219
if success then

0 commit comments

Comments
 (0)