Problem with Force dropping a tool

Hello
I would like my player to be able to have only 1 tool at a time.

I made the following local script, which drops all other tools when a new tool is obtained

local function dropAllTools(exceptTool)
	for _, tool in character:GetChildren() do
		if tool:IsA("Tool") and tool ~= exceptTool then
			tool.Parent = workspace
		end
	end
	for _, tool in player.Backpack:GetChildren() do
		if tool:IsA("Tool") and tool ~= exceptTool then
			tool.Parent = workspace
		end
	end
end
	
character.ChildAdded:Connect(function(tool)
	if tool:IsA("Tool") then
			dropAllTools(tool)
	end
end)

So when I pick a new tool, the old tool is really dropped. However for some reason the dropped tool does not act as a tool anymore and cannot be picked from the ground…
It seems that under the Handle of the dropped tool there is not TouchInterest anymore.
How can I create such?

Thanks in advace

If it’s not re-adding the TouchInterest, it may be disabling the CanTouch property of the handle, maybe try enabling / disabling the CanTouch property when it’s dropped?

local function dropAllTools(exceptTool)
	for _, tool in character:GetChildren() do
		if tool:IsA("Tool") and tool ~= exceptTool then
			tool.Parent = workspace
			tool.Handle.CanTouch = false
			tool.Handle.CanTouch = true
		end
	end
	for _, tool in player.Backpack:GetChildren() do
		if tool:IsA("Tool") and tool ~= exceptTool then
			tool.Parent = workspace
			tool.Handle.CanTouch = false
			tool.Handle.CanTouch = true
		end
	end
end

I doubt it’ll do much but it may be worth a shot?

Edit: Like @DevAqua1 said, it’s because it’s in a local script

I tried this, even added task.wait, but it does not work…
However now I managed to do it in a Server script…
May be it is not possible to parent a tool to the workspace in a Local script?

because the tools need to be dropped in a server sided script.

2 Likes

Sometimes, the problem is the Handle itself. Is it big enough to be taken? and as @DevAqua1 said, it should be done on server side