Hello I'm working on a DataStore script for a game I plan to release real soon and to make updating it in the future a lot easier I need to figure out how to save any newly created values in the datastore. For example whenever a player buys a specific item, instead of having a value already written in the DataStore script I want to create the specific instance of the value and it's value and have those saved instead. Is this doable and if so how would I go about doing this?
Here's some of my current DataStore script:
local key = "user-"..plyr.userId
local storeditems = DataStore:GetAsync(key)
if storeditems then
money.Value = storeditems[1]
shirt.Value = storeditems[2]
pants.Value = storeditems[3]
for i,v in pairs(storage:GetChildren()) do
v.Value = storeditems[i+3]
end
else
repeat
wait(5*60)
local items =
{plyr.Data.Money.Value,plyr.Data.CurrentShirt.Value,plyr.Data.CurrentPants}
for i,v in pairs(plyr.Data.Storage:GetChildren()) do
table.insert(items,i+3,plyr.Data.Storage[v.Name].Value)
end --Save any newly bought items?
print("Saving Data...")
DataStore:SetAsync(key, items)
DataStore:SetAsync(plyr.userId,os.time())
wait(2)
print("Data Saved!")
until plyr == nil
end
Thanks in advance for any help!

2 comments
I fixed your tabbing. Please do this yourself in the future.
That doesn't really help.... My tabbing was fine, makes it easier to read for me. Nvm I figured out a solution.