My Tool Save Script is not working

I meant where and how you save the data using :SetAsync

Oh wait you are right, let me go ahead and rewrite this I will reply when I am done.

I would try this:

local toolsDS = dss:GetDataStore("ToolsData")

local toolsFolder = game.ServerStorage.ToolsFolder

game.Players.PlayerAdded:Connect(function(plr)

	local toolsSaved = toolsDS:GetAsync(plr.UserId .. "-tools") or {}

	for i, toolSaved in pairs(toolsSaved) do

		if toolsFolder:FindFirstChild(toolSaved) then 

			toolsFolder[toolSaved]:Clone().Parent = plr.Backpack
			toolsFolder[toolSaved]:Clone().Parent = plr.StarterGear 
		end
	end

	plr.CharacterRemoving:Connect(function(char)

		char.Humanoid:UnequipTools()
        local tableOfTools = plr.Backpack:GetChildren()
        toolsDS:SetAsync(plr.UserId .. "-tools", tableOfTools)
	end)
end)
1 Like

I tried that code and then got this error

This is because ROBLOX objects are not able to be saved in a datastore. Instead, try serializing the data or only store information about the tool which is unique for each one.

The script he made tries to save the actual tool instead of the name of it

Please, use pcall().

We literally can’t help you or anything if you’re just gonna show us the loading part of the script.

I would try this:

local toolsDS = dss:GetDataStore("ToolsData")

local toolsFolder = game.ServerStorage.ToolsFolder

game.Players.PlayerAdded:Connect(function(plr)

	local toolsSaved = toolsDS:GetAsync(plr.UserId .. "-tools") or {}

	for i, toolSaved in pairs(toolsSaved) do

		if toolsFolder:FindFirstChild(toolSaved) then 

			toolsFolder[toolSaved]:Clone().Parent = plr.Backpack
			toolsFolder[toolSaved]:Clone().Parent = plr.StarterGear 
		end
	end

	plr.CharacterRemoving:Connect(function(char)

		char.Humanoid:UnequipTools()
        local tableOfTools = {}
        for i, v in pairs(plr.Backpack:GetChildren()) do
              table.Insert(tableOfTools,v.Name)
        end 
        toolsDS:SetAsync(plr.UserId .. "-tools", tableOfTools)
	end)
end)

I edited this response, It should work now

Do you need the put the indexes they go to or they don’t have to put in the table in an order

Im pretty sure it indexes it automatically

Ok that’s what I figured would happen

I thought that should work but it ended up with no error and no results is it because table of items was not specified?

try
table.Insert(tableOfItems,v.Name,#tableOfItems+1)
for the line that says
table.Insert(tableOfItems,v.Name)

Still No Changes, it doesn’t save and there’s no errors I dont know what it could be.

A thing I can think of is the part where you Clone(). Few months ago, I ran into this wierd issue where I couldn’t clone myself, and after a bunch of searches I found out it was because of a property called Archivable which needed to be set to true in order to clone, try changing the Archivable properties of your weapons in the script or in the properties list, Atleast see if this might be why

The Problem is that archivable on both tools are set to true

ok then thats not the issue, One second

1 Like

Thank you for helping me with this issue i really appreciate it.

Is it that you never even had a tool to begin with, so it didn’t save because you had none, and it loaded nothing because you had none