local datastoreService = game:GetService("DataStoreService")
local PlayerTools = datastoreService:GetDataStore("PlayerTools")
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(character)
task.wait(10)
print("10 seconds pased")
local suucces, inventory = pcall(function()
return PlayerTools:GetAsync(plr.UserId)
end)
if suucces then
for _, toolName in inventory do
print(toolName)
end
else
print("Could not get data")
end
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
local backpack = plr.Backpack
local char = plr.Character
local myTools = {}
if backpack then
for _, tool in backpack:GetChildren() do
if tool:IsA("Tool") then
table.insert(myTools,tool.Name)
print(myTools[1])
end
end
end
if char then
for _, tool in char:GetChildren() do
if tool:IsA("Tool") then
table.insert(myTools, tool.Name )
print(myTools[tool.Name])
end
end
end
local succes, err = pcall(function()
return PlayerTools:SetAsync(plr.UserId, myTools)
end)
if succes then
print(myTools[1])
else
print(err)
end
end)
when I was simply cloning the tool in character added and set its parent to player backpack it was printing the tool name, but now it prints nil when leaving