Accessory tool not gripping

I have an accessory as a tool and im trying to get it to grip on equip but sometimes, it fails to equip.

local tool = script.Parent
local HandlePart = tool:WaitForChild("HandlePart")
local HandleMotor = HandlePart:WaitForChild("HandleMotor")

local function Unequip()
	if HandleMotor then
		HandleMotor.Enabled = false
		HandleMotor.Part0 = nil
		HandleMotor.Part1 = nil
	end
end

local function Equip(character)
	local RightHand = character:FindFirstChild("RightHand")

	if RightHand and HandleMotor then
		HandleMotor.Part0 = RightHand
		HandleMotor.Part1 = HandlePart
		HandleMotor.Enabled = true
	end
end

local function CheckParent(child, parent)
	if parent and parent.ClassName == "Model" then
		Equip(parent)
	else
		Unequip()
	end
end

CheckParent(tool, tool.Parent)

tool.AncestryChanged:Connect(CheckParent)