I've done Leaderstats but I don't know how to save values.
01 | local DS = game:GetService( "DataStoreService" ):GetDataStore( "Data" ) |
02 |
03 | local StatName = "Cash" |
04 |
05 | game.Players.PlayerAdded:Connect( function (user) |
06 | user.leaderstats:FindFirstChild(StatName).Value = DS:GetAsync(user.UserId) |
07 | end ) |
08 | game.Players.PlayerRemoving:Connect( function (user) |
09 | DS:SetAsync(user.UserId,user.leaderstats:FindFirstChild(StatName).Value) |
10 | 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