If you’re unsure that your code is going to work or need help with debugging your code, please post it in #help-and-feedback:scripting-support next time.
Your code technically works, but it may not work all the time. If the datastores are down, you won’t be able to handle loading and saving properly which will lead to data loss.
On a side note, using SetAsync to update a player’s data is not a good method to use as this completely overrides the previous data.
If you want to handle datastores efficiently, wrap your code in pcalls, add retries and auto save with coroutines.
No, GetAsync takes one argument. I’m not sure if this will cause an error or ignore the second argument. Also, saveTable will go out of scope when you leave this function, as it’s local (it will go away). Do something like this instead
local playerdata = {} --an array of save data for every player, put this at the top of the script you are using
local function loadData(player)
local saveTable = playerdata[player.UserId]
saveTable = {}
saveTable.values = {}
local LoadedData = testDataStore:GetAsync(player.UserId)
saveTable.values.money = LoadedData.values.money
saveTable.values.days = LoadedData.values.days
saveTable.values.daysWait = LoadedData.values.daysWait
end
It still needs some more work, as data stores can fail, and if data fails to load and the game thinks the player is new (so their money will start at 0, for example), their data will be overwritten with 0 money and they will lose their data when the game saves to the data store. I recommend you look into pcall and research what can go wrong with Roblox data stores.