So, I got the script from toolbox and I edited it a little bit. I tested it out, but it didn't work.
Here's the script:
local DSService = game:GetService('DataStoreService'):GetDataStore("DataStore")
game.Players.PlayerAdded:connect(function(plr)
-- Define variables
local uniquekey = 'id-'..plr.userId
-- GetAsync
local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
game.Players.leaderstats.Money.Value = GetSaved[1]
else
local NumbersForSaving = {game.Players.leaderstats.Money.Value}
DSService:SetAsync(uniquekey, NumbersForSaving)
end
end)
game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id-'..plr.userId
local Savetable = {plr.leaderstats.Cash.Value}
DSService:SetAsync(uniquekey, Savetable)
end)
