Advertisement
Guest User

Code

a guest
Jul 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.54 KB | None | 0 0
  1. local DS = game:GetService("DataStoreService")
  2. local WCDS = DS:GetDataStore("WoodchoppingDatastore")
  3.  
  4. game.Players.PlayerAdded:Connect(function(plr)
  5.     --Create leaderstats folder
  6.     local LeaderstatsFolder = Instance.new("Folder", plr)
  7.     LeaderstatsFolder.Name = "leaderstats"
  8.    
  9.     local Vals = Instance.new("Folder", plr)
  10.     Vals.Name = "vals"
  11.    
  12.     local Id = plr.UserId
  13.    
  14.     local Coins = Instance.new("IntValue", LeaderstatsFolder)
  15.     local Wood = Instance.new("IntValue", LeaderstatsFolder)
  16.     local Rebirths = Instance.new("IntValue", LeaderstatsFolder)
  17.     local Strength = Instance.new("IntValue", LeaderstatsFolder)
  18.    
  19.     local EquipedPack = Instance.new("StringValue", Vals)
  20.     local hasBoughtBigBP = Instance.new("BoolValue", Vals)
  21.     local hasBoughtOOFBP = Instance.new("BoolValue", Vals)
  22.     local hasBoughtStoneBP = Instance.new("BoolValue", Vals)
  23.     local hasBoughtGrassBP = Instance.new("BoolValue", Vals)
  24.     local hasBoughtGhostBP = Instance.new("BoolValue", Vals)
  25.     local hasBoughtOldIronBP = Instance.new("BoolValue", Vals)
  26.    
  27.    
  28.    
  29.     Coins.Name = "Coins"
  30.     Wood.Name = "Wood"
  31.     Rebirths.Name = "Rebirths"
  32.     Strength.Name = "Strength"
  33.    
  34.     EquipedPack.Name = "EP"
  35.     hasBoughtBigBP.Name = "BBBP"
  36.     hasBoughtOOFBP.Name = "BOB"
  37.     hasBoughtStoneBP.Name = "BSB"
  38.     hasBoughtGrassBP.Name = "BGB"
  39.     hasBoughtGhostBP.Name = "BGHB"
  40.     hasBoughtOldIronBP.Name = "BOIB"
  41.    
  42.     local LoadTbl = WCDS:GetAsync(Id)
  43.    
  44.     if LoadTbl == nil then
  45.         LoadTbl = {
  46.             0,
  47.             0,
  48.             0,
  49.             1,
  50.             "BasicBackpack",
  51.             {false, false, false, false, false, false},
  52.             {}
  53.             }
  54.     end
  55.    
  56.     Coins.Value = LoadTbl[1]
  57.     Wood.Value = LoadTbl[2]
  58.     Rebirths.Value = LoadTbl[3]
  59.     Strength.Value = LoadTbl[4]
  60.    
  61.     EquipedPack.Value = LoadTbl[5]
  62.     hasBoughtBigBP.Value = LoadTbl[6][1]
  63.     hasBoughtOOFBP.Value = LoadTbl[6][2]
  64.     hasBoughtStoneBP.Value = LoadTbl[6][3]
  65.     hasBoughtGrassBP.Value = LoadTbl[6][4]
  66.     hasBoughtGhostBP.Value = LoadTbl[6][5]
  67.     hasBoughtOldIronBP.Value = LoadTbl[6][6]
  68.    
  69. end)
  70. game.Players.PlayerRemoving:Connect(function(plr)
  71.     plr:WaitForChild("leaderstats")
  72.    
  73.     local Id = plr.UserId
  74.    
  75.         game.ReplicatedStorage.RESaved:FireClient(plr)
  76.         local Coins = plr.leaderstats.Coins.Value
  77.         local Wood = plr.leaderstats.Wood.Value
  78.         local Rebirths = plr.leaderstats.Rebirths.Value
  79.         local Strength = plr.leaderstats.Strength.Value
  80.        
  81.         local EquipedPack = plr.vals.EP.Value
  82.         local BBBP = plr.vals.BBBP.Value
  83.         local BOB = plr.vals.BOB.Value
  84.        
  85.         local SaveTbl = {
  86.            
  87.             Coins,
  88.             Wood,
  89.             Rebirths,
  90.             Strength,
  91.             EquipedPack,
  92.             {BBBP, BOB},
  93.             {}
  94.             }
  95.        
  96.         WCDS:SetAsync(Id, SaveTbl)
  97. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement