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

How do i make tools not save when i destroy them?

okay so i didnt really know what to put in the thumbnail but this is my problem

local DSS = game:GetService("DataStoreService")
local DS = DSS:GetDataStore("BackpackSave")

game.Players.PlayerAdded:Connect(function(player)
	pcall(function()
		local tool = DS:GetAsync("User-"..player.UserId)
		 if tool then
			for i,v in pairs(tool) do
			  local ToolFound = game.ReplicatedStorage.Tools:FindFirstChild(v)
				if ToolFound then
	              ToolFound:Clone().Parent = player.Backpack
	              ToolFound:Clone().Parent = player.StarterGear
									
		  end		
	   end			
	end	
end)
end)	
	
game.ReplicatedStorage.UpdateInventory.OnServerEvent:Connect(function(player)
		pcall(function()
	  	local ToolsSaved = {}
	for i, tool in pairs(player.Backpack:GetChildren()) do
		if tool then
			table.insert(ToolsSaved, tool.Name)
		
 end
end 
DS:UpdateAsync("User-"..player.UserId, ToolsSaved)	
		
end)	
end)

game.Players.PlayerRemoving:Connect(function(player)
		pcall(function()
	  	local ToolsSaved = {}
	for i, tool in pairs(player.Backpack:GetChildren()) do
		if tool then
			table.insert(ToolsSaved, tool.Name)
			
			
	   end
	end 
DS:SetAsync("User-"..player.UserId, ToolsSaved)
end)
end)

this is my serverscript that is supposed to handle the data it does work but when i :Destroy() the tools from local script during the game they still save when u rejoin and i cant understand why?

1 answer

✓ Accepted answer

You are destroying a tool locally.That does not replicate to the server. Consider destroying them on the server instead.

3 comments

0

well the tool is in the players backpack and isnt that local? I thought abt this and i tried doing it from the server but it doesnt seem to work either and i didnt test it with other people but i think it would destroy their tools too wouldnt it?

0

If I have a tool in my backpack, and I use a localscript to destroy that tool. The destruction of that tool will not be registerd on the server.

0

I figured it out u gave me an idea thank you :)

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