Facebook
From Sweltering Moth, 2 Years ago, written in Lua.
This paste is a reply to leaderstats from olimaly - view diff
Embed
Download Paste or View Raw
Hits: 307
  1. local MoneyStore = game:GetService("DataStoreService"):GetDataStore("MoneyData")
  2. local RebirthStore = game:GetService("DataStoreService"):GetDataStore("RebirthData")
  3. local EyeStore = game:GetService("DataStoreService"):GetDataStore("EyesData")
  4.  
  5.  
  6. game.Players.PlayerAdded:Connect(function(plr)
  7.         local leaderstats = Instance.new("Folder")
  8.         leaderstats.Name = "leaderstats"
  9.         leaderstats.Parent = plr
  10.  
  11.         local money = Instance.new("IntValue")
  12.         money.Name = "Coins"
  13.         money.Value = MoneyStore:GetAsync(plr.UserId) or 0
  14.         money.Parent = leaderstats
  15.         local Rebirths = Instance.new("IntValue")
  16.     Rebirths.Name = "Rebirths"
  17.         Rebirths.Value = RebirthStore:GetAsync(plr.UserId) or 0
  18.         Rebirths.Parent = leaderstats
  19.         local Eyes = Instance.new("IntValue")
  20.         Eyes.Name = "Eyes"
  21.         Eyes.Value = EyeStore:GetAsync(plr.UserId) or 0
  22.         Eyes.Parent = leaderstats
  23.  
  24.  
  25. end)
  26.  
  27. game.Players.PlayerRemoving:Connect(function(plr)
  28.  
  29.         MoneyStore:SetAsync(plr.UserId, plr.leaderstats.Coins.Value)
  30.         RebirthStore:SetAsync(plr.UserId, plr.leaderstats.Rebirths.Value)
  31.         EyeStore:SetAsync(plr.UserId, plr.leaderstats.Eyes.Value)
  32. end)