game.Players:GetPlayesr() and game.Players.LocalPlayer difference please?
LocalPlayer is the client running the script (therefore it has to be in a local script)
GetPlayers returns a table with all the players in the server including LocalPlayer (if you are running it from a localscript) and can be called from anywhere (a localscript or a script)
Get players gets all the players in game.Players and returns the results as a table
game.Players.LocalPlayer is a reference to the player in a local script.
GetPlayers() Hold all the online Players in the Server and put it in a Table/Array (see here):
-- We are in a Server with two Players: Player1 and Player2 local AllActivePlayers = game.Players.GetPlayers() print(AllActivePlayers) ----> Player1 and Player2
LocalPlayer is you self. Exemple: You Play a Roblox game with your Friend. For You and the Server, you are the LocalPlayer (you self) and your Friend is another, not LocalPlayer (a NormalPlayer(see here)).
Difference??? The LocalPlayer is a Player/NormalPlayer and LocalScripts work with him. Wenn you use a LocalPlayer and LocalScript, only the LocalPlayer can see or interact with something (Example a Gui, only you see your Gui. You cant see the Gui of your Friend. You cannot see the Gui of Your Friend)
Is very hard to explain LocalPlayer