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

what is the difference beetween :GetPlayers() and .LocalPlayer?

Asked by 5 years ago

game.Players:GetPlayesr() and game.Players.LocalPlayer difference please?

0
game.Players:GetPlayers() Is A table. game.Players.LocalPlayer is an Instance. The Instance would be that player. http_shawn 1 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago

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)

1
oh no, you beat me to it. nice description. royaltoe 5144 — 5y
0
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 GGRBXLuaGG 417 — 5y
Ad
Log in to vote
0
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago

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.

Log in to vote
0
Answered by 5 years ago

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

Answer this question