Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. local DS = game:GetService("DataStoreService")
  2. local inventoryStore = DS:GetDataStore("InventoryStore")
  3. local RS = game:GetService("ReplicatedStorage")
  4. local moduleScript = game:GetService("ServerScriptService").ModuleScript
  5. local inventory = require(moduleScript)
  6.  
  7. game.Players.PlayerAdded:Connect(function(player)
  8.    
  9.     local key = player.UserId.."-Inventory"
  10.     pcall(function()
  11.         local inventory_data = inventoryStore:GetAsync(key)
  12.         if inventory_data then
  13.             print("1")
  14.             for i, v in pairs(inventory_data) do
  15.                 local tool = inventory[v]
  16.                 if tool then
  17.                     print("2")
  18.                     local clone = tool:Clone()
  19.                     clone.Parent = player:WaitForChild("Backpack")
  20.                     clone.Parent = player:WaitForChild("StarterGear")
  21.                 end
  22.             end
  23.         end
  24.     end)
  25. end)
  26.  
  27. game.Players.PlayerRemoving:Connect(function(player)
  28.    
  29.     local key = player.UserId.."-Inventory"
  30.     pcall(function()
  31.         local Inventory = {}
  32.         player.Character.Humanoid:UnequipTools()
  33.         for i, v in pairs(player.Backpack:GetChildren())do
  34.             if v then
  35.                 print("3")
  36.                 table.insert(Inventory,v.Name)
  37.             end
  38.         end
  39.         inventoryStore:SetAsync(key,Inventory)
  40.     end)
  41. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement