UnequipTools() is not working

I tried looking at other topics with this issue but nothing seemed to really connect with my issue, I have a microwave system and it unequips the tool once u use it, but i destroy it right after, the only issue is the tools animation is still playing once this is done, I even went into the tool to see if the unequip wasnt working and it is, so im confused why this setup causes it?

local function MashedPotatos(player,character,tool)
	if character and character:FindFirstChild("Humanoid") then
	character:FindFirstChild("Humanoid"):UnequipTools()
	task.wait()
	tool:Destroy()
	ready = true

So ur saying that, after you destroy the tool, the tool animation is still playing?

you mean the character animation right?

if thats the case, you need to deactivate the loop option when you load the animation.

for example:

local animplay = animator:LoadAnimation(script.Animation)
animplay.Looped = false

Its the idle animation I have for the tool, simple hold animation. but it needs to loop when equipped so it doesnt just stop after a couple seconds, the unequip tools should be unequipping it causing the animation to stop before i even destroy it

When you load the animation, the animation name will name the loaded animation, what i mean is:

local animplay = animator:LoadAnimation(script.Something)

The loaded animation at the animator is called “Something”

You could just do a loop at the animator currently playing animation tracks, and just stop the specific animation animation.

for example:

local function MashedPotatos(player,character,tool)
	if character and character:FindFirstChild("Humanoid") then
		character:FindFirstChild("Humanoid"):UnequipTools()
		task.wait()
		tool:Destroy()
		local hum:Humanoid = character:WaitForChild("Humanoid")
		local animator:Animator = hum:WaitForChild("Animator")
		for i,v in ipairs(animator:GetPlayingAnimationTracks()) do
			if v.Name == "Something" then
				v:Stop()
			end
		end
		ready = true
	end
end

Hope it helps!

I was actually able to just throw this one line in between the unequip and the destroy and it works like a charm, I figured the task.wait wouldve given it plenty of time to do what it needed to do but I guess not!

	character:FindFirstChild("Humanoid"):UnequipTools()
		repeat wait() until not character:FindFirstChildOfClass("Tool")
	tool:Destroy()

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