I have been stuck with this problem for about five hours or so...
First time I asked this question, I was incredible tired, that's why I wanna ask the question with a little more explanation of my problem.
Don't worry. I have deleted my first post. No spam. ^^
My problem is:
local DataStore = game:GetService("DataStoreService") local DataList = DataStore:GetDataStore("UserData") function savedata(dataname, playerid, value) DataStore:GetDataStore(dataname):SetAsync(playerid, value) --print("Datastore: ", value) end --This is the default data, will be set for new players DefaultData = { ["Level"] = 2, ["Xp"] = 0, ["Coins"] = 0, ["Gems"] = 0, }; --Setting default data to new players game:GetService("Players").PlayerAdded:Connect(function(plr) pcall(function() local Data = DataList:GetAsync(plr.UserId) if Data == nil then Data = DefaultData end savedata("UserData", plr.UserId, Data) end) end) --This is what I've tried to do, but totally failed with local Data = DataList:GetAsync(plr.UserId) savedata(Data.Xp, plr.UserId, 100) savedata(Data["Xp"], plr.UserId, 100)
I understand that I made some questions in my last post, and I want to answer them here.
Q. Do you want to change the data inside the "DefaultData" table?
A. No, I do not want to change the data inside the "DefaultData" table. I wanna change the data inside the table inside the "UserData" datastore.
Q. Do you want a way to change the data after its created
A. Yes, In a way, I want that. I want to get the data from the datastore, and change the data that I get from the datastore, in other words, save it with different information.
Q. Do you need help with getting the values inside the table?
A. No. I know how to get the values, but not how to change it.
Thanks in advance
~WaterFoox
This?
local Data = DataList:GetAsync(plr.UserId) Data.XP = 100