When I watch some scripting videos, then I see alot when it says local Player = game.Players.LocalPlayer
I know what the rest means. But I'm wondering what LocalPlayer is. What is it? Why is it useful? Etc.
Thank you,
Ducksneedhelp
Simple answer, local player is the player.
Long answer...
Games have "2-sides", client and server. The client would be the player, while the server would be... well, the server. Now, what LocalPlayer does is it gets the current player. Since the server contains everyone's player, it does not know which one to take, thus returning nil. Although, when LocalPlayer is used on the client-side, in a LocalScript, the client only has 1 "player"(In quotes because other players can exist but they are not controlled by the same user.), so LocalPlayer would return that player. This essentially works the same way as say...
game.Players.PlayerAdded:Connect(function(player) --blah blah blah end)
In this function, we create a variable called player, that variable is the player that just joined. This function here would go inside of server and would run anytime a player joins the server(only for the player or for the entire server depending on what you have inside).
TL;DR; LocalPlayer returns the player used by the client