Whenever tool and animations are destoryed, animations still play

So whenever you would sell a tool which basically gives money to the player and destroys the tool, the gun would be destroyed but the animations would be stuck on the idle animation

I’ve literally tried so many methods but they all arent working

here’s the script

local prox = script.Parent
local amount = 3000

prox.Triggered:Connect(function(player)
	local GUN1 = player.Character:FindFirstChild("AKS-74U")
	local animations = GUN1:FindFirstChildOfClass("Animation")
	if GUN1 then
		player.leaderstats.Cash.Value += 3000
		animations:Destroy()
		GUN1:Destroy()
	end
end)

I really need some help on this since im not very good with animationtracks and such

for i,v in pairs(Humanoid.Animator:GetPlayingAnimationTracks()) do v:Stop() end

where would i put that on the script?

Set Humanoid to player.Character.Humanoid, and place the line anywhere after that.

alright ill try that, thank you so much

Okay so i did this, but its still not working, any ideas on why?

local prox = script.Parent
local amount = 3000

prox.Triggered:Connect(function(player)
	local GUN1 = player.Character.Humanoid:FindFirstChild("AKS-74U")
	local animations = GUN1:FindFirstChildOfClass("Animation")
	if GUN1 then
		player.leaderstats.Cash.Value += 3000
		for i,v in pairs(Humanoid.Animator:GetPlayingAnimationTracks()) do v:Stop() end
		animations:Destroy()
		GUN1:Destroy()
	end
end)

Before the line you need to add local Humanoid = player.Character.Humanoid.

Well, i tried to make it work and it isnt, ill just find another way to make this script, thank you for the help!

One last thing… Did you check the output?

no i didnt, why?

CHARS)))))))))))))

I just wanted to be sure there wasn’t any errors.

yeah there wasnt any, well thank you so much for the help bro

1 Like

never mind

CHARS)))))))))))))))))))))

Here’s a related post I found: Animations sometimes still continuing after being stopped - Help and Feedback / Scripting Support - DevForum | Roblox Good luck.

oh alright, thank you so much!!!