Advertisement
fomm1802

Leaderstats SAVE

Dec 23rd, 2021
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. local dsService = game:GetService("DataStoreService")
  2. local ds = dsService:GetDataStore("MondStats")
  3.  
  4. game.Players.PlayerAdded:Connect(function(plr)
  5. local folder = Instance.new("Folder", plr)
  6. folder.Name = "leaderstats"
  7. local currency = Instance.new("IntValue", folder)
  8. currency.Name = "Cash"
  9. currency.Value = ds:GetAsync(plr.UserId) or 0
  10. currency.Changed:Connect(function()
  11. ds:SetAsync(plr.UserId, currency.Value)
  12. end)
  13. end)
  14.  
  15. game.Players.PlayerRemoving:Connect(function(plr)
  16. ds:SetAsync(plr.UserId, plr.leaderstats.Cash.Value)
  17. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement