Advertisement
Guest User

Leader Board Save Data

a guest
Dec 13th, 2019
5,400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. --script made by the crispydevvv
  2.  
  3. local dsService = game:GetService("DataStoreService")
  4. local ds = dsService:GetDataStore("CoinStats") --rename 'coinstats' to whatever you want that doesnt affect the script!
  5.  
  6. game.Players.PlayerAdded:Connect(function(plr)
  7. local folder = Instance.new("Folder", plr)
  8. folder.Name = "leaderstats"
  9. local currency = Instance.new("IntValue", folder)
  10. currency.Name = "Coins" --change 'coins' to your currency name
  11. currency.Value = ds:GetAsync(plr.UserId) or 0
  12. currency.Changed:Connect(function()
  13. ds:SetAsync(plr.UserId, currency.Value)
  14. end)
  15. end)
  16.  
  17. game.Players.PlayerRemoving:Connect(function(plr)
  18. ds:SetAsync(plr.UserId, plr.leaderstats.Coins.Value) --also change 'coins' to your currency value
  19. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement