Yeah that is exactly what I thought but wasnt sure tho thanks for the information!
I made a section of my tutorial explaining about that if you’d like to read it.
Yeah that is exactly how I thought it was I just checked it it is also the way I work thanks tho and I think many people will appreciate your tutorial! Keep up the good work!
I’m just now realising that the stats reset on me…
Kept the same way (i think)
local Datastore = game:GetService("DataStoreService")
local Datakey1 = 640725831
local Datastore1 = Datastore:GetDataStore(Datakey1)
game.Players.PlayerAdded:Connect(function(plr)
for _, folder in pairs(script.Datastores:GetDescendants()) do
if folder:IsA('Folder') then
local Header = folder:Clone()
Header.Parent = plr
PlayerData[plr] = {}
local Data = Datastore1:GetAsync(plr.UserId)
for _, value in pairs(Header:GetDescendants()) do
if value.ClassName:match('Value') then
value.Value = Data and Data[value.Name] or 0
PlayerData[plr][value.Name] = value.Value
if value.Name:match('Booster') and value.Value < 1 then
value.Value = 1
end
value.Changed:Connect(function()
PlayerData[plr][value.Name] = value.Value
end)
end
end
--Datastore1:SetAsync(plr.UserId,PlayerData[plr])
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
Datastore1:SetAsync(plr.UserId,PlayerData[plr])
end)
When and how did the stats reset?
It is also better to do PlayerData[plr][value.Name] = value.Value
after the booster
I don’t even know. It reset like every 3-4 games (in studio). Does datastoring not function correctly orrr…
By the way, sorry for bugging you.
Its alright if SetAsync doesnt work good enough I suggest you use UpdateAsync it works much better than SetAsync in my opinion SetAsync overwrites data and can cause sometimes data loss but UpdateAsync just updates the data so it will just update the data and not overwrite it.
Hope this will help and you can always send me if you need me
PS: it can also be helpfull to wrap the GetASync in a pcall to check if the code works without errors and so you can also check if the data gets returned
If you don’t have an advanced knowledge of cacheing, I would recommend using something like DataStore2 that can handle all of that for you for absolute security. I work with SQL all the time for production environments, and DataStore just has too many problems that I’d rather just do it with
DS2 than write massive cacheing and backup methods.