How to insert values to a table of a dictionary

i have a dictionary like the following

{
   ["Player 1"] = {},
   ["Player 2"] = {},
}

i would like how know how to insert value to them like this without replacing the value to the new value. The reason is I’m planning to add more values later on
Table["Player 1"] = {["money1"] = 100, ["money2"] = 200}

3 Likes

You can use the table.insert() function to create a table.
EDIT: My mistake I didn’t get the question 1 sec

You can index the table like this?

data["Player 1"]["money1"]
1 Like
table.insert(Your Table[Player1], money)

Table.insert simply adds values inside the table, doesnt change them nor remove them, not sure what you mean

if you want a bunch of the same values, just do this:

if table.find(Table[Player1], money) then
print("Already in table")
else
table.insert(Table[Player1], money)
end
1 Like

If you want to just add an entry to the table, you can use table.insert():
table.insert(Table[“Player 1”], {[“money1”] = 100, [“money2”] = 200})

4 Likes

hi how can i do
table.insert(Table[“Player 1”], {[“money1”] = 100, [“money2”] = 200})
without making a new table

something like this
table.insert(Table[“Player 1”], [“money1”] = 100)

Since your using dictionaries you could simply do this.
(assuming Table[“Player 1”] is a table)

Table["Player 1"].money1 = 100

-- or

Table["Player 1"]["money1"] = 100
5 Likes

Thank you! i would mark as solution but the original post was made for different a question.

1 Like

That’s fine don’t worry! All that matters is if your question was answered :+1: : :smile:

edit: omg i used thumbs down sorry.

2 Likes

You can’t do that. You can only insert tables into other tables.

1 Like

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