Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local datastore = game:GetService("DataStoreService")
- local cashStorage = datastore:GetDataStore("CashDataStore")
- game.Players.PlayerAdded:Connect(function(player)
- local leaderstats = Instance.new("Folder")
- leaderstats.Name = "leaderstats"
- leaderstats.Parent = player
- local cash = Instance.new("IntValue")
- cash.Name = "Cash"
- cash.Parent = leaderstats
- cash.Value = cashStorage:GetAsync(player.UserId).Cash
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local data = {
- Cash = player:FindFirstChild("leaderstats").Cash.Value
- }
- cashStorage:SetAsync(player.UserId, data)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement