Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I create a table to go on a value already in a table?

Asked by 4 years ago

So basically I'm making an item saver, it saves via the items name (Such as "Basic Sword") but part of my game will be weapon upgrades, enchanting and such.

The saving works so far but currently doesn't save the values within the sword.

How would one create a table connected to the value. Such as:

local saveTable = {SwordA = {Upgrade=12, Enchant="CritChance3", Effect="Circle5"}, SwordB = {Upgrade=5, Enchant="Sharp5", Effect="Spark3"}}

My script currently is as follows:

01local dataStore = game:GetService("DataStoreService")
02local itemSaves = dataStore:GetDataStore("playersItems")
03 
04local gameItemsFolder = game.ServerStorage.Items
05local swordFolder = gameItemsFolder.Swords
06local potionFolder = gameItemsFolder.Potions
07 
08local function saveItems(lostPlayer)
09    local Key = lostPlayer.UserId .. "-Items"
10    local SaveTable = {Swords={}, Potions={}}
11 
12    local starterGear = lostPlayer:WaitForChild("StarterGear")
13 
14    for _,item in pairs(starterGear:GetChildren()) do
15        if item:FindFirstChild("weaponServer") then
View all 95 lines...

Answer this question