game.Players:GetPlayesr() and game.Players.LocalPlayer difference please?
what is the difference beetween :GetPlayers() and .LocalPlayer?
3 answers
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)
2 comments
oh no, you beat me to it. nice description.
Thank you :D I love how you are answering a lot of questions lately, I am not one of the OPs but thank you :D
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
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
game.Players:GetPlayers() Is A table. game.Players.LocalPlayer is an Instance. The Instance would be that player.