Table.insert names the table as numbers

hello everyone.

I’m trying to make a system to save player’s data per game such as their inventory what buildings they own etc.

however I’m having an issue regarding inserting the table which contain the data and reading it from another script

this function is inside the module script which also contains the table which contain every player’s data:

function PlayerData.AddPlayer(player)
	table.insert(PlayerData.PlayerList, {[player.Name] = {
	["Plots"] = 0,
	}}  )
end

however when I use table.insert the name of the table is a number instead of the player’s name which makes it difficult to read the data from other scripts.

is there a way to make it something like this:

[player name here] = {
[Plots] = 0
}

instead of:

[1] = {
[player name here] = {
[Plots] = 0 
}}

thank you

table library works with arrays not dictionaries

instead do this:

PlayerData.PlayerList[player.UserId] = {
[“Plots”] = 0,
}

1 Like

If this has helped please mark it as a solution