--Click to Equip Script
--Unless you know what you're doing, do not modify this script.

local tool = script.Parent.Parent --This indicates the tool for the handle.
script.Parent.Parent = tool.Parent --This removes the "Touch to Equip" function for the handle.
script.Parent.ClickDetector.MouseClick:Connect(function(plr) --This detects a click on the handle.
	local character = plr.Character --This identifies the player's character.
	local humanoid = character:FindFirstChild("Humanoid") --This identifies "Humanoid".
	if humanoid ~= nil then --This ensures that "Humanoid" exists inside the player's character.
		tool.Parent = character --This causes the character to equip the tool.
		script.Parent.Parent = tool --This puts the handle inside the tool.
		tool.AncestryChanged:Connect(function(item) --This detects a change in the tool's ancestry.
			local parent = item.Parent --This identifies the parent of the tool.
			if parent.Name ~= "Backpack" and parent ~= character and script.Parent.Parent == tool then
				--The code above ensures the parent isn't the player's backpack or character, and the handle is inside the tool.
				script.Parent.Parent = tool.Parent --This ensures that "Touch to Equip" is disabled.
			end
		end)
	end
end)
