How to add more values to a specific table?

Hi, I am doing a rpg game right now, and my weapons system it’s like this, since i you can’t obtain them normally (on the floor, things like that), but by a Module Manager i have, i got this :

-- itemNameHereInfo.lua
return {
    id = "1",
    name = "Sword",
    itemType = "Weapon", -- ranged.. -- consumable
    damage = 20, --
    maxAmmo = 30 -- 
}

-- playerData
{
    ["123"] = {
        bonusDamage = 5 -- player bought an upgrade to their weapon which boosts damage
       -- more values here, like the one above or changing the name  , how would i add more custom values ? (ex. "bonusAmmo")
    }
}

So yeah, the question is how to add values to a already made table

i tried doing things like :

["123"].bonusAmmo = 25 , but it throws nil
1 Like

Here are some examples

local BaseTable = {
    Cheese = true,
    Other = {
        Bonus = 30
    }
}

BaseTable['NewValue'] = 300
BaseTable.Other['NewValue'] = true
1 Like

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