local service = game:GetService("DataStoreService")
local datastore = service:GetDataStore("hleol")
game.Players.PlayerAdded:Connect(function(Player)
if datastore:GetAsync(Player.userId) then
for i, v in pairs(datastore:GetAsync(Player.userId)) do
print(v)
local tool = game.ServerStorage[v]:Clone()
tool.Parent = Player.Backpack
end
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
local ToolsToSave = { }
for i, v in pairs(Player.Backpack:GetChildren()) do
table.insert(ToolsToSave, v.Name)
end
print("a")
datastore:SetAsync(Player.userId, ToolsToSave)
end)
At line 9, it does not parent it to the backpack. I tried with workspace, and it worked. But backpack seem to not be broken. Any fix?

2 comments
you need to wait for the character to be added and then clone the tool to the backpack
also userId is deprecated, use UserId