Tool.Unequipped not firing or being detected when unequipped on server

Tool.Unequipped isnt firing properly

local MotorGrip = nil

local function GripFunction(State)
	local OldGrip = RightArm:WaitForChild("RightGrip")

	if State == true then
		MotorGrip = Instance.new("Motor6D", Torso)
		MotorGrip.Name, MotorGrip.Part0, MotorGrip.Part1 = "RightGrip", Torso, Handle
	elseif State == false then
		if MotorGrip then
			DebrisService:AddItem(MotorGrip, 0)
			MotorGrip = nil
		end
	end
	OldGrip.Enabled = false
end

local function Equip()
	GripFunction(true)
end

local function Unequip()
	GripFunction(false)
end

Tool.Equipped:Connect(function()
	Equip()
	warn("EQUIP")
end)

Tool.Unequipped:Connect(function()
	Unequip()
	warn("UNEQUIP")
end)

Is this a localscript or a server sided one?

I could be wrong, but I think this is happening because of this line:

local OldGrip = RightArm:WaitForChild("RightGrip")

I’m assuming that it ends up waiting because after the tool is unequip there is no “RightGrip” anymore and so then it waits, with then after it is requiped then it exists, so it runs the rest after