There were no errors. The print one is below the ‘Untitled Game auto-recovery file was created’.
Hm… for the PlayerRemoving
event, can you replace it with this?
game.Players.PlayerRemoving:Connect(function(player)
local success, response = pcall(function()
local toolSave = {}
for i, tool in pairs(player.Backpack:GetChildren()) do
if tool then
table.insert(toolSave,tool.Name)
print("Added ".. tool.Name .." to ".. player.Name .."'s table.")
end
end
wait()
datastore:SetAsync("User-"..player.UserId,toolSave)
end)
if success then
print("Successfully saved ".. player.Name .."'s data")
else
print("Failed to save ".. player.Name .."'s data")
end
end)
It kind of works.
It duplicated the tools. XD
Here is the output:
Don’t worry about the duplication of the tool. I can probably fix it.
I cannot thank you enough. Thank you so much! Your help is extremely appreciated!
1 Like
Try this, that should solve the problem!
game.Players.PlayerRemoving:Connect(function(player)
local success, response = pcall(function()
local toolSave = {}
for i, tool in pairs(player.Backpack:GetChildren()) do
if tool and not table.find(toolSave, tool.Name) then
table.insert(toolSave,tool.Name)
print("Added ".. tool.Name .." to ".. player.Name .."'s table.")
end
end
wait()
datastore:SetAsync("User-"..player.UserId,toolSave)
end)
if success then
print("Successfully saved ".. player.Name .."'s data")
else
print("Failed to save ".. player.Name .."'s data")
end
end)
Thanks! I will try it out! Thank you again!
1 Like