Table insert for every players

Players.PlayerAdded:Connect(function(Player)
   local Table = {}
   table.insert(Table[Player], {})
end)

i want the table to print something like this
{ [Player 1] = {}, [Player 2] = {} }
but i’m not sure how to do so correctly without overriding it when new player joins
when i do table.insert(Table, Player) it sets the player as the value and not index

1 Like

Two problems. The first is that you can’t create dictionaries with table.insert.
Table[Player] = {}
The second is that you just need to move local Table to the outside of the event.

3 Likes
local Table = {}

Players.PlayerAdded:Connect(function(Player)
   Table[Player] = {}
end)

Doing this will create a new key for the dictionary, and make the value an empty table. If said player already exists, then you can edit the value to something else.

4 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.