How would I insert a dictionary into tables?

Title says it all. But i’ll try to describe what i’m trying to get across.
Code:

PlayerData[Player] = {
	['XP'] = 0;
	['Coins'] = 2500;
	['Diamonds'] = 0;
	['Fireworks'] = 0;
	['CaseKeys'] = 0;
	['Unboxings'] = 0;
	['SeasonOne'] = false;
	['KnifeInventory'] = {{"Default", 1}};
	['KnifeEquipped'] = "Default";
	['PetInventory'] = {{"Rabbit", 1}};
	['PetEquipped'] = "Rabbit";
	['Codes'] = {};
}
--- I want to add ['RadioInventory'] = {} & ['EffectInventory'] = {};

I want to add a radioInv and a effectInv to players who’ve already played the game and had their tables (data) already saved. How could I do this?

I don’t think you could use table.insert for this one.

1 Like

So basically you have something like this?

local PlayerData = {
["Player1"] = {data1 = 2, data2 = 3...};
["Player2"] = {data1 = 6, data2 = 7...};
...
}
2 Likes

Yes

PlayerData[Player] = {
		['XP'] = 0;
		['Coins'] = 2500;
		['Diamonds'] = 0;
		['Fireworks'] = 0;
		['CaseKeys'] = 0;
		['Unboxings'] = 0;
		['SeasonOne'] = false;
		['KnifeInventory'] = {{"Default", 1}};
		['KnifeEquipped'] = "Default";
		['PetInventory'] = {{"Rabbit", 1}};
		['PetEquipped'] = "Rabbit";
		['Codes'] = {};
}
--- I want to add ['RadioInventory'] = {} & ['EffectInventory'] = {};

I want to add a radioInv and a effectInv to players who’ve already played the game and had their tables (data) already saved.

1 Like

Technically, this should work:

for player, data in pairs(PlayerData) do
      PlayerData[player]["RadioInventory"] = {}
      PlayerData[player]["EffectInventory"] = {}
end
1 Like

It works, I been trying to figure this out for awhile now, thank you

1 Like