Advertisement
xmaanzach

Save Leaderstats

May 13th, 2018
2,573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. --// local variables
  2. local DataStore = game:GetService("DataStoreService")
  3. local save1 = DataStore:GetDataStore("CashSave")
  4.  
  5. -- PlayerAdded Event Function
  6. game.Players.PlayerAdded:connect(function(player)
  7. local cash = player:WaitForChild("leaderstats").Cash
  8.  
  9. cash.Value = save1:GetAsync(player.UserId) or 0
  10. save1:SetAsync(player.UserId, cash.Value)
  11.  
  12. --// Changed Event Function
  13. cash.Changed:connect(function()
  14. save1:SetAsync(player.UserId, cash.Value)
  15. end)
  16. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement