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.
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