Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What does game.players.localplayers do?

2 answers

First of all, it's game.Players.LocalPlayer not LocalPlayers. Its function is to get the client or the player itself (you). Note: You can only use it in a local script. This is an example of using it.

--LocalScript
local player = game.Players.LocalPlayer --for example your username is Roblox

while task.wait(5) do
	print(player.Name) --this prints your username, which is "Roblox"
end

Hello Buddy,

LocalPlayer is a player. Its an ordinary player, its actually just the client. So basically its you playing the game. LocalPlayers and LocalScripts are just replicated. only LocalScript can access the local player while normal Scripts can access every Player in the game. lets say for example, you have a toy, and you say its mine so basically its just yours. While your parents that provide you with toys is the server replicating you with toys. LocalPlayer can do stuff with the character in the game which can be referenced like:

Code Example, referencing LocalPlayer

local Plr = game.Players.LocalPlayer  <---

LocalPlayer has a character, PlayerGui, Backpack, Starter PlayerScripts etc.

This discussion is preserved as it was. New answers, comments, and votes are closed.