BumpyPlayz

Leaderstats Twitter Code Gui [Lua]

Oct 5th, 2019
4,208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.48 KB | None | 0 0
  1. -- variables
  2.  
  3. local dsService = game:GetService("DataStoreService")
  4. local ds = dsService:GetDataStore("leader")
  5.  
  6. -- main code
  7.  
  8. game.Players.PlayerAdded:Connect(function(player)
  9.     local folder = Instance.new("Folder", player)
  10.     folder.Name = "leaderstats"
  11.     local cash = Instance.new("IntValue", folder)
  12.     cash.Name = "Cash"
  13.     cash.Value = ds:GetAsync(player.UserId) or 0
  14.    
  15.     -- auto saving script
  16.     cash.Changed:Connect(function()
  17.         ds:SetAsync(player.UserId, cash.Value)
  18.     end)
  19. end)
Add Comment
Please, Sign In to add comment