Here is my script
CashData = game:GetService("DataStoreService"):GetDataStore("CashData")
GemsData = game:GetService("DataStoreService"):GetDataStore("GemsData")
game.Players.PlayerAdded:connect(function(plr)
local stats = Instance.new('IntValue', plr)
stats.Name = 'leaderstats'
local cash = Instance.new('IntValue', stats)
cash.Name = 'Cash'
cash.Value = 0
stats.Name = 'leaderstats'
local cash = Instance.new('IntValue', stats)
cash.Name = 'Gems'
cash.Value = 0
end)
I tried to make it autosave but it wont work, i tried two diffrent ways but this is all ive got

5 comments
you can use a numeric for loop for lines 21 and 22, and you dont need to check if :GetAsync() returns nil or not
also he can put the values inside separate datastores if he wants
I think multiple DataStores saving at once counts as more “saves”, and gets you needlessly closer to the save cap, right?
Yea.
@ EXpodo1234ALT separate datastores - bad idea, cuz why if you can put many data in one datastore?