Advertisement
Guest User

Untitled

a guest
Aug 16th, 2022
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. local players = game.Players
  2. local DSS = game:GetService("DataStoreService")
  3. local DataStore = DSS:GetDataStore("DataStore")
  4.  
  5. players.PlayerAdded:Connect(function(plr)
  6. local leaderstats = Instance.new("Folder")
  7. leaderstats.Name = "leaderstats"
  8.  
  9. local coins = Instance.new("IntValue")
  10. coins.Name = "Coins"
  11. coins.Value = 250 -- change this to whatever you want, preferable a low value
  12.  
  13.  
  14. local bag = Instance.new("IntValue")
  15. bag.Name = "Bag"
  16. bag.Value = 0
  17.  
  18. local data
  19. local success, errorMessage = pcall(function()
  20. data = DataStore:GetAsync(plr.UserId)
  21. end)
  22. if success and data ~= nil then
  23. print("Data successfully loaded!")
  24. coins.Value = coins.info-- If you named Cash to Money, write Money here instead
  25. else
  26. warn(errorMessage)
  27. end
  28.  
  29. leaderstats.Parent = plr
  30. coins.Parent = leaderstats
  31. bag.Parent = leaderstats
  32. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement