I think you want to use “profile” as the table name, so it should look like this:
local function giveItem(profile, name, rarity, status)
table.insert(profile["weapons"]["guns"], {name, rarity, status})
end
-- Calling Function
giveItem("Inventory", "GunName", "GunRarity", "GunStatus")