Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ You can also combine functions inside a `Class.LocalScript|LocalScript`. For exa

```lua
local MarketplaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local button = script.Parent

-- Replace the placeholder ID with your developer product ID
Expand Down
6 changes: 4 additions & 2 deletions content/en-us/reference/engine/classes/Backpack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ description: |
The Backpack can be accessed from both the client and the server.

```lua
local Players = game:GetService("Players")

-- Accessing Backpack from a Server Script:
game.Players.PlayerName.Backpack
local backpack = Players.PlayerName.Backpack

-- Accessing Backpack from a LocalScript:
game.Players.LocalPlayer.Backpack
local backpack = Players.LocalPlayer.Backpack
```
code_samples:
- Backpack-Give-Tool
Expand Down
7 changes: 5 additions & 2 deletions content/en-us/reference/engine/classes/GuiObject.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1417,11 +1417,14 @@ events:
of the user's mouse relative to a GUI element:

```lua
local Players = game:GetService("Players")

local CustomScrollingFrame = script.Parent
local SubFrame = CustomScrollingFrame:FindFirstChild("SubFrame")

local mouse = game.Players.LocalPlayer:GetMouse()
function getPosition(X, Y)
local mouse = Players.LocalPlayer:GetMouse()

local function getPosition(X, Y)
local gui_X = CustomScrollingFrame.AbsolutePosition.X
local gui_Y = CustomScrollingFrame.AbsolutePosition.Y

Expand Down
2 changes: 1 addition & 1 deletion content/en-us/reference/engine/classes/Object.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ methods:
end
end
end
paintFigure(game.Players.Player.Character, BrickColor.new("Bright blue"))
paintFigure(game:GetSerivce("Players").Player.Character, BrickColor.new("Bright blue"))
```

Since all classes inherit from `Class.Object`, calling
Expand Down
4 changes: 2 additions & 2 deletions content/en-us/reference/engine/classes/Tool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ events:
```lua
local tool = Instance.new("Tool")
tool.RequiresHandle = false
tool.Parent = game.Players.LocalPlayer.Backpack
tool.Parent = game:GetSerivce("Players").LocalPlayer.Backpack

function onActivation()
print("Tool activated")
Expand Down Expand Up @@ -425,7 +425,7 @@ events:
```lua
local tool = Instance.new("Tool")
tool.RequiresHandle = false
tool.Parent = game.Players.LocalPlayer.Backpack
tool.Parent = game:GetSerivce("Players").LocalPlayer.Backpack

function toolDeactivated()
print("Tool deactivated")
Expand Down
2 changes: 1 addition & 1 deletion content/en-us/reference/engine/classes/Translator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ methods:
local LocalizationService = game:GetService("LocalizationService")

local success, translator = pcall(function()
return LocalizationService:GetTranslatorForPlayerAsync(game.Players.LocalPlayer)
return LocalizationService:GetTranslatorForPlayerAsync(game:GetSerivce("Players").LocalPlayer)
end)

if success then
Expand Down
Loading