ProtonDev-Sys

Untitled

Dec 7th, 2020
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. game.ReplicatedStorage.add.OnServerEvent:Connect(function(plr)
  2. plr.leaderstats.Coins.Value += 1
  3. end)
  4.  
  5. local datastore = game:GetService("DataStoreService"):GetDataStore('Data')
  6. game.Players.PlayerAdded:Connect(function(plr)
  7. local data = datastore:GetAsync(plr.UserId)
  8.  
  9. local l = Instance.new("Folder")
  10. l.Name = 'leaderstats'
  11. l.Parent = plr
  12.  
  13. local value = Instance.new('IntValue')
  14. value.Name = 'Coins'
  15. print(data)
  16. if data then
  17. value.Value = data['Coins']
  18. end
  19. value.Parent = l
  20. end)
  21.  
  22. game.Players.PlayerRemoving:Connect(function(plr)
  23. datastore:SetAsync(plr.UserId,{
  24. ['Coins'] = plr.leaderstats.Coins.Value
  25. })
  26. end)
Add Comment
Please, Sign In to add comment