Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DS = game:GetService("DataStoreService")
- local inventoryStore = DS:GetDataStore("InventoryStore")
- local RS = game:GetService("ReplicatedStorage")
- local moduleScript = game:GetService("ServerScriptService").ModuleScript
- local inventory = require(moduleScript)
- game.Players.PlayerAdded:Connect(function(player)
- local key = player.UserId.."-Inventory"
- pcall(function()
- local inventory_data = inventoryStore:GetAsync(key)
- if inventory_data then
- print("1")
- for i, v in pairs(inventory_data) do
- local tool = inventory[v]
- if tool then
- print("2")
- local clone = tool:Clone()
- clone.Parent = player:WaitForChild("Backpack")
- clone.Parent = player:WaitForChild("StarterGear")
- end
- end
- end
- end)
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local key = player.UserId.."-Inventory"
- pcall(function()
- local Inventory = {}
- player.Character.Humanoid:UnequipTools()
- for i, v in pairs(player.Backpack:GetChildren())do
- if v then
- print("3")
- table.insert(Inventory,v.Name)
- end
- end
- inventoryStore:SetAsync(key,Inventory)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement