diff --git a/content/en-us/production/monetization/developer-products.md b/content/en-us/production/monetization/developer-products.md index 6a94a6f3c..bd77f4f87 100644 --- a/content/en-us/production/monetization/developer-products.md +++ b/content/en-us/production/monetization/developer-products.md @@ -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 diff --git a/content/en-us/reference/engine/classes/Backpack.yaml b/content/en-us/reference/engine/classes/Backpack.yaml index d3e25f6ba..6e06f0f1b 100644 --- a/content/en-us/reference/engine/classes/Backpack.yaml +++ b/content/en-us/reference/engine/classes/Backpack.yaml @@ -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 diff --git a/content/en-us/reference/engine/classes/GuiObject.yaml b/content/en-us/reference/engine/classes/GuiObject.yaml index 9abc38a55..8fb06c5ef 100644 --- a/content/en-us/reference/engine/classes/GuiObject.yaml +++ b/content/en-us/reference/engine/classes/GuiObject.yaml @@ -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 diff --git a/content/en-us/reference/engine/classes/Object.yaml b/content/en-us/reference/engine/classes/Object.yaml index 2b6c4b37d..8e7e9dc65 100644 --- a/content/en-us/reference/engine/classes/Object.yaml +++ b/content/en-us/reference/engine/classes/Object.yaml @@ -155,6 +155,8 @@ methods: `Datatype.BrickColor` property: ```lua + local Players = game:GetService("Players") + local function paintFigure(character, color) -- Iterate over the child objects of the character for _, child in character:GetChildren() do @@ -165,7 +167,7 @@ methods: end end end - paintFigure(game.Players.Player.Character, BrickColor.new("Bright blue")) + paintFigure(Players.Player.Character, BrickColor.new("Bright blue")) ``` Since all classes inherit from `Class.Object`, calling diff --git a/content/en-us/reference/engine/classes/Tool.yaml b/content/en-us/reference/engine/classes/Tool.yaml index 9ab17daf0..08441b7a9 100644 --- a/content/en-us/reference/engine/classes/Tool.yaml +++ b/content/en-us/reference/engine/classes/Tool.yaml @@ -391,9 +391,11 @@ events: player clicks while the created tool is equipped. ```lua + local Players = game:GetService("Players") + local tool = Instance.new("Tool") tool.RequiresHandle = false - tool.Parent = game.Players.LocalPlayer.Backpack + tool.Parent = Players.LocalPlayer.Backpack function onActivation() print("Tool activated") @@ -423,9 +425,11 @@ events: player releases their click while the tool is equipped and activated. ```lua + local Players = game:GetService("Players") + local tool = Instance.new("Tool") tool.RequiresHandle = false - tool.Parent = game.Players.LocalPlayer.Backpack + tool.Parent = Players.LocalPlayer.Backpack function toolDeactivated() print("Tool deactivated") diff --git a/content/en-us/reference/engine/classes/Translator.yaml b/content/en-us/reference/engine/classes/Translator.yaml index 8c38175ad..1630e3105 100644 --- a/content/en-us/reference/engine/classes/Translator.yaml +++ b/content/en-us/reference/engine/classes/Translator.yaml @@ -209,10 +209,11 @@ methods: text as the second argument: ```lua + local Players = game:GetService("Players") local LocalizationService = game:GetService("LocalizationService") local success, translator = pcall(function() - return LocalizationService:GetTranslatorForPlayerAsync(game.Players.LocalPlayer) + return LocalizationService:GetTranslatorForPlayerAsync(Players.LocalPlayer) end) if success then