local service = game:GetService("DataStoreService")
local datastore = service:GetDataStore("lolaaaa1uh9")
local toolstosave = { }

game.Players.PlayerAdded:Connect(function(Player)
	if datastore:GetAsync(Player.userId) then
		for i, v in pairs(datastore:GetAsync(Player.userId)) do
			print(v)
		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
	datastore:SetAsync(Player.userId, toolstosave)
end)

Sometimes, it does not print anything when I join, even though I left with tools. Any fix?

2 comments

0

Seems to me like your code crashes, I have no idea as to why this is happening, but maybe experiment with a wait function possibly before the tools load in.

0

All datastore calls are able to error.