What does game.Players.LocalPlayer mean?
What does game.Players.LocalPlayer mean?
4 answers
The way ROBLOX works, there are different computers doing different parts of the work.
The ROBLOX game server does most of the work. All Script objects are all run by the Server.
But, because the server is away over the network, if it did everything, the clients (players playing the game) would have a short delay before anything happens.
Imagine hovering over a button, and seeing it change color only 100ms after your mouse gets there, or your gun not firing for a second and then lagging behind the mouse.
LocalScripts are scripts which each client runs. They are specific to a particular player. Which player is decided by where the LocalScriptis (inside a Character, PlayerGui, Backpack).
The player whose computer is running the LocalScript is identified by the Players service's LocalPlayer property. (This property is nil when a regular Script asks for it).
It is a Player object, which is the object that has a Character, TeamColor, and userId property, as well as others.
LocalPlayer is exactly what it says. The local player. It can only be accessed in a local script.
it is exactly like a normal player, it just provides easy access for local scripts.
This means that it is getting the local player. So say you were in game and someone said players = game.Players.LocalPlayer... that means that it is getting you character since your the local player.
It is basically what pull said. game.Players.LocalPlayer it goes into game , then into Players , then LocalPlayeris you, so when you go to players and get the local.Player, you are the local player. You can even get your character through it by doing game.Players.LocalPlayer.Character. Hope this helped.
This discussion is preserved as it was. New answers, comments, and votes are closed.
