I've done Leaderstats but I don't know how to save values.
✓ ANSWER ACCEPTED
How do i save a value in Datastore?
2 answers
✓ Accepted answer
local DS = game:GetService("DataStoreService"):GetDataStore("Data")
local StatName = "Cash"
game.Players.PlayerAdded:Connect(function(user)
user.leaderstats:FindFirstChild(StatName).Value = DS:GetAsync(user.UserId)
end)
game.Players.PlayerRemoving:Connect(function(user)
DS:SetAsync(user.UserId,user.leaderstats:FindFirstChild(StatName).Value)
end)
Save and load script. Basic save and load, It can be made better using UpdateAsync() but this will also work.
Take a look at this question's top answer, while the question isn't completely related, the answer should probably help you out
https://scriptinghelpers.org/questions/41698/how-to-save-multiple-values-in-a-datastore
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You should use :IncrementAsync().