Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesnt my tool saving script work when you rejoin the game?

When I leave with a tool in my inventory and join back it simply does not give me the tool

local ds = game:GetService("DataStoreService"):GetDataStore("ToolSave")
 game.Players.PlayerAdded:connect(function(plr)
 local key = "id-"..plr.userId
 pcall(function() 
	local tools = ds:GetAsync(key)
	 if tools then 
		for i,v in pairs(tools) do 
			local tool = game.ServerStorage.Tools:FindFirstChild(v)
			 if tool then
				 tool:Clone().Parent = plr:WaitForChild("Backpack")
				 tool:Clone().Parent = plr:WaitForChild("StarterGear")
			 end
		 end
	 end 
end) 
end) 
game.Players.PlayerRemoving:connect(function(plr) 
	local key = "id-"..plr.userId 
	pcall(function()
		 local toolsToSave = {}
		 for i,v in pairs(plr.Backpack:GetChildren()) do
			 if v then 
				table.insert(toolsToSave,v.Name)
			 end 
		end
		 ds:SetAsync(key,toolsToSave)
	 end) 
	end) 

1 comment

0

Funny I have the same script and am having the same problem lol

1 answer

Okay so this answer is a bit easier than I originally thought. I was using this script also, a friend of mine originally wrote it and I was having the same problem as you.I was driving myself crazy trying to figure out what was going wrong and why it wouldn't save tools upon coming back into the game.

What I figured out was that I had API services enabled in Roblox Studio and for some reason or another it was messing with the datastore whenever I went into studio and edited the script or played it in studio. After I unchecked enable API services it started working 100% better.

I hope this helps you. I know it helped me.

This discussion is preserved as it was. New answers, comments, and votes are closed.