Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TeleportService = game:GetService("TeleportService")
- local ToolsFolder = game:GetService("ServerStorage"):WaitForChild("SavedTools")
- local DataStoreService = game:GetService("DataStoreService")
- local SaveData = DataStoreService:GetDataStore("SaveData")
- game.Players.PlayerAdded:Connect(function(player)
- local ToolData = SaveData:GetAsync(player.UserId)
- local Backpack = player:WaitForChild("Backpack")
- local StarterGear = player:WaitForChild("StarterGear")
- if ToolData ~= nil then
- for i, v in pairs(ToolData) do
- if ToolsFolder:FindFirstChild(v) and Backpack:FindFirstChild(v) == nil and StarterGear:FindFirstChild(v) == nil then
- ToolsFolder[v].Parent = Backpack
- ToolsFolder[v].Parent = StarterGear
- end
- end
- end
- player.CharacterRemoving:Connect(function(character)
- character:WaitForChild("Model"):UnequipTools()
- end)
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local ToolsTable = {}
- for i, v in pairs(player.Backpack:GetChildren()) do
- table.insert(ToolsTable, v.Name)
- end
- if ToolsTable ~= nil then
- SaveData:SetAsync(player.UserId, ToolsTable)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement