Facebook
From UNLIMITED TYCOON, 3 Years ago, written in Lua.
This paste is a reply to Re: leaderstats from Little Sloth - view diff
Embed
Download Paste or View Raw
Hits: 210
  1. local MoneyStore = game:GetService("DataStoreService"):GetDataStore("MoneyData")
  2.  
  3.  
  4. game.Players.PlayerAdded:Connect(function(plr)
  5.         local leaderstats = Instance.new("Folder")
  6.         leaderstats.Name = "leaderstats"
  7.         leaderstats.Parent = plr
  8.  
  9.         local money = Instance.new("IntValue")
  10.         money.Name = "Coins"
  11.         money.Value = MoneyStore:GetAsync(plr.UserId) or 0
  12.         money.Parent = leaderstats
  13.        
  14.        
  15.  
  16.  
  17. end)
  18.  
  19. game.Players.PlayerRemoving:Connect(function(plr)
  20.  
  21.         MoneyStore:SetAsync(plr.UserId, plr.leaderstats.Coins.Value)
  22.  
  23.        
  24. end)
captcha