Hello!
So I have this code but for some reason when I rejoin the game, it does not give my tools back.
Did I do anything wrong?
local ToolsData = {}
local function AddToolInTable(tool)
table.insert(ToolsData, tool)
end
for i, tool in pairs(player.Backpack:GetChildren()) do
if tool then
if tool:IsA("Tool") then
AddToolInTable(tool:Clone())
end
end
end
for i, tool in pairs(player.Character:GetChildren()) do
if tool:IsA("Tool") then
if tool then
AddToolInTable(tool:Clone())
end
end
end
local Success, ErrorMessage = pcall(function()
DataStore:SetAsync(player.UserId, Data)
ToolsDataStore:SetAsync(player.UserId, ToolsData)
end)