Advertisement
NameDevv

Roblox Data Save

Oct 30th, 2018
6,929
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. -- Created By NameDevv On Roblox --
  2. -- Subscribe To Name Devv On YouTube --
  3. -- Turn On Post Notifications For More Script´s --
  4.  
  5.  
  6.  
  7. local DataStore = game:GetService("DataStoreService"):GetDataStore("PlayerStats")
  8.  
  9. function playerAdded(plr)
  10.  
  11. local stats = Instance.new("StringValue");
  12. stats.Parent = plr;
  13. stats.Name = "leaderstats";
  14.  
  15. local cash = Instance.new("IntValue");
  16. cash.Parent = stats;
  17. cash.Name = "Cash";
  18.  
  19. local usr = "user_" .. plr.userId;
  20.  
  21. DataStore:UpdateAsync(usr, function(oldValue)
  22.  
  23. local theNewValueYouWant = 0;
  24.  
  25. if (oldValue ~= nil) then
  26. theNewValueYouWant = 0;
  27. end
  28.  
  29. return theNewValueYouWant;
  30. end)
  31.  
  32. cash.Value = DataStore:GetAsync(usr);
  33. end
  34.  
  35. game.Players.PlayerAdded:connect(playerAdded);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement