SHARE
TWEET

Untitled

a guest Nov 19th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top