Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DSService = game:GetService('DataStoreService'):GetDataStore('Hamburger223232')
- game.Players.PlayerAdded:connect(function(plr)
- -- Define variables
- local uniquekey = 'id-'..plr.UserId
- local leaderstats = Instance.new('IntValue',plr)
- local savevalue = Instance.new('IntValue')
- leaderstats.Name = 'leaderstats'
- savevalue.Parent = leaderstats
- savevalue.Name = 'Cash'
- -- GetAsync
- local GetSaved = DSService:GetAsync(uniquekey)
- if GetSaved then
- savevalue.Value = GetSaved[1]
- else
- local NumbersForSaving = {savevalue.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)
Advertisement
Add Comment
Please, Sign In to add comment