My idea was to create tables including stats of any player that joins the game.
Plrs.PlayerAdded:Connect(function(Plr)
PlayerData[Plr.UserId] = {}
for name, v in PlayerStats do
table.insert(PlayerData[Plr.UserId], name)
end
print(PlayerData)
end)
Both PlayerData and PlayerStats are created manually
I managed to create a table with custom index set as UserID. As I said, those tables will hold information about player stats, however, I did not found any way to table.insert new values into it that ALSO have custom indexes.
Result of my code, first table is what I want to achive, another is added by my script.
Plrs.PlayerAdded:Connect(function(Plr)
PlayerData[Plr.UserId] = {}
for name, v in PlayerStats do
PlayerData[Plr.UserId][name] = v
end
print(PlayerData)
end)
When Player joins the game, script will get his UserID and make new table named by his ID.
My goal was to insert those values to freshly created user table.