Advertisement
TheRealJinx

ROBLOX Wallet LeaderStats [Working]

Aug 16th, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1.  
  2. local currencyName = "Wallet"
  3. local DataStore = game:GetService("DataStoreService") :GetDataStore("TestDataStore")
  4.  
  5. game.Players.PlayerAdded:Connect(function(player)
  6.  
  7. local folder = Instance.new("Folder")
  8. folder.Name = "leaderstats"
  9. folder.Parent = player
  10.  
  11. local currency = Instance.new("IntValue")
  12. currency.Name = currencyName
  13. currency.Parent = folder
  14.  
  15. local ID = currencyName..""..player.UserId
  16. local savedData = nil
  17.  
  18. pcall(function()
  19. savedData = DataStore:GetAsync(ID)
  20. end)
  21.  
  22. if savedData ~= nil then
  23. currency.Value = savedData
  24. print("Data loaded")
  25. else
  26. -- New player
  27. currency.Value = 50
  28. print("New player to the game")
  29. end
  30.  
  31. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement