How to stop tools from being equipped when the player picks them up

When the player touches a tool, it will be instantly picked up and equipped if the tool has a Handle. There is no way to prevent this behavior, but here is the best work-around I could come up with.

Rename your Handle to pickupPart, and then add a Script under the tool.
image

Put this code in the script:

-- Services
local Players = game:GetService("Players")

-- parts
local tool = script.Parent

-- Ensure either the pickupPart or Handle part is assigned to this variable
local pickupPart = script.Parent:FindFirstChild("pickupPart")
if not pickupPart then
	pickupPart = script.Parent:FindFirstChild("Handle")
end

pickupPart.Touched:Connect(function(otherPart)
	-- If the other part belongs to a character of a player
	if otherPart.Parent:FindFirstChild("Humanoid") then
		-- Get the player
		local player = Players:GetPlayerFromCharacter(otherPart.Parent)
		if player ~= nil then
			pickupPart.Name = "Handle"
			wait(0.1)
			script.Parent.Parent = player.Backpack
		end
	end
end)

-- Rename the handle if the tool is moved in or out of the backpack
script.Parent.AncestryChanged:Connect(function(child, parent)
	if parent:IsA("Backpack") then
		wait(0.1)
		pickupPart.Name = "Handle"
	end
	if parent == game.Workspace then
		pickupPart.Name = "pickupPart"
	end
end)

EDIT: Added code to rename the handle if the tool is in a backpack in case the tool is added by some other method.
EDIT 2: Added some additional logic and waits to prevent errors and make part equip correctly / pickup and drop consistently

7 Likes

That’s a neat workaround, simple and effective, I like it!

Does renaming the Handle prevent it from being picked up completely? If so, this idea could be extended to only allow some people to pick up the tool, or at a specific time, or with other conditions, etc…

3 Likes

Yes, the tool does not automatically pick up unless there is a part named Handle

1 Like

Really simple tutorial. I originally had separated the Handle, placed in in the Workspace, and stored the tool in ServerStorage, before basically implementing a similar code.

Ig it doesn’t make a difference either :thinking:

I have done something like this before, ended up basically having to make a model and a tool for every tool, and store them in folders in replicated storage. pretty messy… I wish there was a property on the tool to handle this functionality like “AutoEquip”

1 Like