How to insert values to 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

[Player 1] = {["money1"] = 100, ["money2"] = 200}
2 Likes

You can’t actually do that, it has to be a string.

['Player 1']

Also this is how you do it.

Table['Player1'] = {['money1'] = 100, ['money2'] = 200}

-- or you can do this V

local i = 1
Table['Player' .. i] = {['money1'] = 100, ['money2'] = 200}
7 Likes

sorry to bother you again but what how would i insert extra values maybe like money 3 without overriding the previous variables. i was told to not use table.insert for dictionaries

1 Like
Table['Player1']['money3'] = 100
5 Likes

Are you sure this doesn’t clear the previous tables. If so then there’s something wrong with my code

1 Like

Yes, it does not clear the previous tables. There might be somerthing wrong with your code.

2 Likes

thank you for your time, ill mark as solution again

2 Likes

But it might error if Player1 does not exist.

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