I think you mean you wanna get all players in one variable, and others are being confused that you wanna get the local player, because of the question title, Avigant answered correct, if you just wanna get the local player use game.Players.LocalPlayer and to get all use game.Players:GetPlayers() but you need more explanation :
LocalPlayer : A property of Player Service, it's an object value, and the value is your player, you maybe wondering There are a lot players, but it's just one object value, the fact is you need to use local scripts to get local player, you can put local scripts in services like StarterGui, Backpack, StartPlayerScripts, StarterCharacterScripts, when player joins game clones local scripts separately for each player, and they run separately, means if you change anything for a player with local script and your game is fe only local player can see it.
Local Variables : I think you know what are variable, and you had understood what does local exactly mean, but here is a another example :
a :
local a = 1
function change()
local a = 2
end
change()
print(a)
b :
local a = 1
function change()
a = 2
end
change()
print(a)
so that were some more example of local stuffs
and you need table for what you want to do in this question, there are a lot variable types like Boolean, Int, Number, Object, String, Table, EnumValues, Color3, BrickColor and a lot more
Tables : a variable type that holds more than one values, they are also called arrays, a table can hold any variable for example :
local test = {
String = "abc",
Object = workspace.Part,
Number = 123,
Color = Color3.new(1, 1, 1),
Bool = true
}
so now if you type print(test.String) it would print abc and if you type print(test.Number) it would print 123 and if you type test.Object:Destroy() it would destroy workspace.Part
so the thing you can do with players that's :
local Players = game.Players:GetPlayers()
for _, plr in pairs(Players) do
print(plr.Name)
print(plr.Character.HumanoidRootpart.Position)
end
I hope i answered the thing you want to know, thanks for reading.
2 comments
Ohhh! This answer is AWESOME!!! Thanks youuuu!
np