BumpyPlayz

Leaderstats Tool Shop

Feb 5th, 2020
2,619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.52 KB | None | 0 0
  1. local dsService = game:GetService("DataStoreService")
  2. local ds = dsService:GetDataStore("ShopGuiLeaderstats6")
  3.  
  4.  
  5. game.Players.PlayerAdded:Connect(function(player)
  6.    
  7.     local folder = Instance.new("Folder", player)
  8.     folder.Name = "leaderstats"
  9.     local cash = Instance.new("IntValue", folder)
  10.     cash.Name = "Cash"
  11.    
  12.     cash.Value = ds:GetAsync(player.UserId) or 0
  13.    
  14.    
  15.    
  16. end)
  17.  
  18.  
  19. game.Players.PlayerRemoving:Connect(function(player)
  20.    
  21.     local cash = player.leaderstats.Cash
  22.     ds:SetAsync(player.UserId, cash.Value)
  23.    
  24. end)
Add Comment
Please, Sign In to add comment