Unequipped not being called but Equipped works fine

  1. What do you want to achieve?
    Print “Unequipped” when a tool is unequipped and stop playing an animation.

  2. What is the issue?
    When the tool is equipped, it prints
    Screenshot 2023-06-22 191605
    But whenever it’s unequipped it doesn’t print anything.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried printing directly after connecting to unequipped.

The tool should play an animation when its equipped, which it does and stop the animation when unequipped, which it doesn’t do.

local function OnEquip()
	Equipped = true
	
	local Character = Elixir.Parent
	
	
	if Character then
		local Humanoid = Character:WaitForChild("Humanoid")
		
		if Humanoid then
			local CustomAnimator = Humanoid:WaitForChild("CustomAnimator")
			
			if CustomAnimator then
				if not LoadedAnimation then
					LoadedAnimation = CustomAnimator:LoadAnimation(PotionHoldAnimation)
				end
				LoadedAnimation:Play()
			end
		end
	end
end






local function OnUnequip()
	Equipped = false
	
	if LoadedAnimation then
		LoadedAnimation:Stop()
	end
end





Elixir.Equipped:Connect(function()
	print("Equipped.")
	OnEquip()
end)


Elixir.Unequipped:Connect(function()
	print("Unequipped.")
	OnUnequip()
end)

The LoadedAnimation variable is defined at the top of the script.

1 Like

Does your tool have a handle, and is ‘RequiresHandle’ set to true?

If not, thats your reason.

“This event (Unequipped) doesn’t fire when Tool.RequiresHandle is enabled and no handle is present.”

Documentation here.

The tool does have a handle. It’s a union, would that change anything?

Potentially,

does it meet this criteria?

“By default, tools are held in the right hand and have a handle in them, which is a Part named “Handle” inside”

Making the handle a part has the same issue.

The last thing, I personally think could be the issue, try placing Unequipped:Connect above Equipped:Connect.

That didn’t work, but thanks for your help.

I don’t understand the issue, your code is fine at first glance, and also the screenshot you provided shows it printing unequipped. Either there’s an issue somewhere else that you didn’t provide in this snippet or the issue is something else entirely that you aren’t describing since there’s nothing obvious that would make this not functional.

I’ve decided to just start from new. Nothing was making sense on why it wasn’t working, thanks for all your help.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.