Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What does game.players.localplayers do?

Asked by 2 years ago

I'm just wondering what it does, i feel like it grabs the player but i just want to be sure

2 answers

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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
Ad
Log in to vote
0
Answered by 2 years ago

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.

Answer this question