Let's say we create an table and we want to print out our name from all of those other people on the table. For example their is 3 players : Alvin,Bob,Dave and my name is Dave so with an table how can we print out our name locally when i play it should say Dave
local AllPlayers = {} for i,v in pairs(game.Players:GetPlayers) do table.insert(AllPlayers,v) -- What more to add so we can print out the name Print() end)
Rather than adding the players into the table in a for loop, it might be easier to just say:
local AllPlayers = game.Players:GetPlayers()
In your for loop you could then say:
for i,v in pairs(AllPlayers) do Print(v) --V references the value of the specific entry in the table. end)
A lot of things here are being done incorrectly.
For example, you are using multiple tables to achieve something that only requires a simple loop. You aren't actually calling the GetPlayers
function.
Here is a quick fix that is also as compact and neat as possible.
for i,v in pairs(game.Players:GetPlayers()) do print(v.Name) end