Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local datastore = game:GetService("DataStoreService"):GetDataStore("test866818286369716235195685453434369464701")
- game.Players.PlayerAdded:Connect(function(player)
- local lt = Instance.new("Folder")
- lt.Name = "leaderstats"
- lt.Parent = player
- local money = Instance.new("IntValue")
- money.Name = "Cash"
- money.Parent = lt
- local key = "plr-"..player.userId
- local getSaved = datastore:GetAsync(key)
- if getSaved then
- money.Value = getSaved[1]
- else
- local itemsToSave = {money.Value}
- datastore:GetAsync(key, itemsToSave)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- datastore:SetAsync("plr-"..player.userId, {player.leaderstats.Cash.Value})
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement