Advertisement
Guest User

Untitled

a guest
Jul 6th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. local Data = game:GetService("DataStoreService"):GetDataStore("Inventory")
  2. game.Players.PlayerAdded:Connect(function(plr)
  3. local SavedStuff = Data:GetAsync(plr.userId)
  4. if SavedStuff ~= nil then
  5. for i,v in pairs(SavedStuff)do
  6.  
  7. if game.ServerStorage.Item_Category_Example_1:FindFirstChild(v) ~= nil then
  8. local Weapon = game.ServerStorage.Item_Category_Example_1:FindFirstChild(v):Clone()
  9. Weapon.Parent = plr:WaitForChild("Backpack")
  10. end
  11.  
  12. if game.ServerStorage.Item_Category_Example_2:FindFirstChild(v) ~= nil then
  13. local Weapon = game.ServerStorage.Item_Category_Example_2:FindFirstChild(v):Clone()
  14. Weapon.Parent = plr:WaitForChild("Backpack")
  15. end
  16.  
  17. if game.ServerStorage.Item_Category_Example_3:FindFirstChild(v) ~= nil then
  18. local Weapon = game.ServerStorage.Item_Category_Example_3:FindFirstChild(v):Clone()
  19. Weapon.Parent = plr:WaitForChild("Backpack")
  20. end
  21.  
  22. end
  23. end
  24. plr.CharacterRemoving:Connect(function()
  25. plr.Character.Humanoid:UnequipTools()
  26. end)
  27. end)
  28. game.Players.PlayerRemoving:Connect(function(plr)
  29. local Table = {}
  30. for i,v in pairs(plr.Backpack:GetChildren())do
  31. table.insert(Table,v.Name)
  32. end
  33. if Table ~= nil then
  34. Data:SetAsync(plr.userId,Table)
  35. end
  36. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement