Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. local DS = game:GetService("DataStoreService")
  2. local CoinSave = DS:GetDataStore("CoinSave")
  3.  
  4. game.Players.PlayerAdded:Connect(function(Player)
  5. local Folder = Instance.new("Folder")
  6. Folder.Name = "leaderstats"
  7. Folder.Parent = Player
  8.  
  9. local PetInv = Instance.new("Folder")
  10. PetInv.Name = "Pets"
  11. PetInv.Parent = Player
  12.  
  13. local Coins = Instance.new("IntValue")
  14. Coins.Name = "Coins"
  15. Coins.Value = CoinSave:GetAsync(Player.UserId) or 100000
  16. Coins.Parent = Folder
  17. Coins.Changed:Connect(function()
  18. CoinSave:SetAsync(Player.UserId,Coins.Value)
  19. end)
  20. end)
  21.  
  22. game.Players.PlayerRemoving:Connect(function(Player)
  23. CoinSave:SetAsync(Player.UserId,Player.leaderstats("Coins").Value)
  24. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement