Tool Animation Glitch When Tool Destroyed/Removed

When the tool is destroyed/removed from the player, the tool animation kept going. How do I fix this problem?

Here’s the video although its self-explanatory.

Here’s the LocalScript -

local anims = {script.Parent.Hold}
local loadedAnims = {}
local tool = script.Parent
local animator

tool.Equipped:Connect(function(mouse) 
	animator = plr.Character:WaitForChild("Humanoid"):WaitForChild("Animator") 
	if not loadedAnims[1] then
		loadedAnims[1] = animator:LoadAnimation(anims[1])
	end
	loadedAnims[1]:Play()
end)

tool.Unequipped:Connect(function()
	loadedAnims[1]:Stop()
end)
1 Like

I would recommended use the Remote Event.

Because after you did the ProximityPrompt, The Server Script will tell the local script to end the animation.

I’ll give you more information or advice when you reply. :+1:

1 Like

Sure, do enlighten me! :smile:

tool.Destroying:Connect(function()
   -- do stuff here too ya!
end)

(not aware of your other script/how ur actually destroying the tool, etc).

1 Like

Here’s the script inside the Part that destroys the tool when touched:


local Restock = script.Parent

Restock.Touched:Connect(function(Obj)
    if Obj.Parent.Name == "Box" and Obj.Parent:IsA("Tool") then
        local PLAYER_OBJECT = Players:GetPlayerFromCharacter(Obj.Parent.Parent)
        local tool = Obj:FindFirstAncestorWhichIsA("Tool")

        if tool and tool.Name == "Box" then
            tool:Destroy()
        end
    end
end)

I’ve found a fix to this problem. Before destroying the tool, let the player unequip the tool and add a bit of delay before destroying it. Case solved!

Do keep in mind that, on the server-side, the Tool still exists but because of FilteringEnabled this change isn’t communicated to the server but Animations are replicated.

People were mostly over-complicating the fix in this thread, just handle it server-sided as it has the most authority and it replicates to all Clients.

Consider reading up on: Client Replication 101. The guide to replicating effects to clients if you need more clarity.

1 Like

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