Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DS = game:GetService("DataStoreService")
- local WCDS = DS:GetDataStore("WoodchoppingDatastore")
- game.Players.PlayerAdded:Connect(function(plr)
- --Create leaderstats folder
- local LeaderstatsFolder = Instance.new("Folder", plr)
- LeaderstatsFolder.Name = "leaderstats"
- local Vals = Instance.new("Folder", plr)
- Vals.Name = "vals"
- local Id = plr.UserId
- local Coins = Instance.new("IntValue", LeaderstatsFolder)
- local Wood = Instance.new("IntValue", LeaderstatsFolder)
- local Rebirths = Instance.new("IntValue", LeaderstatsFolder)
- local Strength = Instance.new("IntValue", LeaderstatsFolder)
- local EquipedPack = Instance.new("StringValue", Vals)
- local hasBoughtBigBP = Instance.new("BoolValue", Vals)
- local hasBoughtOOFBP = Instance.new("BoolValue", Vals)
- local hasBoughtStoneBP = Instance.new("BoolValue", Vals)
- local hasBoughtGrassBP = Instance.new("BoolValue", Vals)
- local hasBoughtGhostBP = Instance.new("BoolValue", Vals)
- local hasBoughtOldIronBP = Instance.new("BoolValue", Vals)
- Coins.Name = "Coins"
- Wood.Name = "Wood"
- Rebirths.Name = "Rebirths"
- Strength.Name = "Strength"
- EquipedPack.Name = "EP"
- hasBoughtBigBP.Name = "BBBP"
- hasBoughtOOFBP.Name = "BOB"
- hasBoughtStoneBP.Name = "BSB"
- hasBoughtGrassBP.Name = "BGB"
- hasBoughtGhostBP.Name = "BGHB"
- hasBoughtOldIronBP.Name = "BOIB"
- local LoadTbl = WCDS:GetAsync(Id)
- if LoadTbl == nil then
- LoadTbl = {
- 0,
- 0,
- 0,
- 1,
- "BasicBackpack",
- {false, false, false, false, false, false},
- {}
- }
- end
- Coins.Value = LoadTbl[1]
- Wood.Value = LoadTbl[2]
- Rebirths.Value = LoadTbl[3]
- Strength.Value = LoadTbl[4]
- EquipedPack.Value = LoadTbl[5]
- hasBoughtBigBP.Value = LoadTbl[6][1]
- hasBoughtOOFBP.Value = LoadTbl[6][2]
- hasBoughtStoneBP.Value = LoadTbl[6][3]
- hasBoughtGrassBP.Value = LoadTbl[6][4]
- hasBoughtGhostBP.Value = LoadTbl[6][5]
- hasBoughtOldIronBP.Value = LoadTbl[6][6]
- end)
- game.Players.PlayerRemoving:Connect(function(plr)
- plr:WaitForChild("leaderstats")
- local Id = plr.UserId
- game.ReplicatedStorage.RESaved:FireClient(plr)
- local Coins = plr.leaderstats.Coins.Value
- local Wood = plr.leaderstats.Wood.Value
- local Rebirths = plr.leaderstats.Rebirths.Value
- local Strength = plr.leaderstats.Strength.Value
- local EquipedPack = plr.vals.EP.Value
- local BBBP = plr.vals.BBBP.Value
- local BOB = plr.vals.BOB.Value
- local SaveTbl = {
- Coins,
- Wood,
- Rebirths,
- Strength,
- EquipedPack,
- {BBBP, BOB},
- {}
- }
- WCDS:SetAsync(Id, SaveTbl)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement