My Tool Save Script is not working

Hello, I recently made a tool save script for my roblox simulator game, and I tested it out in the actual roblox game after being published, i have api and https requests turned on and it still will not work. So it would be greatly appreciated if anyone could help me, Thanks!

Source Code:

local dss = game:GetService("DataStoreService")
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()
	end)
end)
1 Like

Do your tools save and load in studio?

1 Like

If Fact They Do Not And It Is annoying

I think its because you dont save the tools to the tool datastore

Where in the script is that error?

Well, theres not exactly an error, you just dont save the tools

But the thing is I did Save the tools in the desired folder and in the code the tools are linked to a table in the data store.

Could you provide that code then?

And plus if there was no error then it would save the tools.

Do you ever save the tools in your code?

I did post the code I guess I have to post it again.

local dss = game:GetService("DataStoreService")
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()
	end)
end)

I don’t think it will error if it is a nil value, did you save the name of the tool as a string?

It didn’t error in the output or console screen But I might not have.

I did control f to search for :SetAsync and found no results, what I’m saying is that you never save the tools. You only unequip them.

Oh there is an if statement so if it is a nil it would skip it. That would be why there isn’t an error.

But I am confused because I thought I saved the to a table in the datastore.

Could you provide the line(s) of code where you save? I dont see them

where and how do you save the data

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

That loads the tools, not saves the tools