local Player = game.Players.LocalPlayer
local Animation = script.Parent.Holding
local Axe = script.Parent
local Animator
local LoadedAnimation
Axe.Equipped:Connect(function(mouse)
Animator = Player.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
LoadedAnimation = Animator:LoadAnimation(Animation)
LoadedAnimation:Play()
end)
Axe.Destroying:Connect(function()
LoadedAnimation:Stop()
end)
LoadedAnimation:Stop() doesn’t do anything and the character is still stuck in that pose
Perhaps instead try looping through all the animations being played and end each of them. The normal animations for the character (like walking, idle etc) will resume, but the one you’re trying to stop shouldn’t.
Inside of the last function, try putting:
for i, v in pairs(Player.Character.Humanoid:GetPlayingAnimationTracks()) do
wait()
v:Stop()
end
If that doesn’t solve your issue, go through the normal debugging steps, check to see if the event fires, either by using breakpoints or stick a print statement within the scope of that chunk of code.
You could also try using the .Changed signal to check if the parent on the tool has changed. This is more long winded and is like putting a plaster/bandaid over a stab wound, it’ll cover up an issue but the underlying issue will still be there
Axe.Changed:Connect(function(Prop)
if Prop == "Parent" then
LoadedAnimation:Stop()
end
end)
Some other things to note with the :Stop() event, you can add a fade-out time parameter to fade out the animation over a period of time. That was a useful thing I didn’t learn until the last project I did. Good thing to know.
Same thing I said to Crygen, the axe is unequipped by destroying it, which sends a copy to replicated storage for later use. Yes it is a custom inventory system
Try determinating the animator and the loadedanimation variables before the function. And, as i know, when you unequip a tool roblox moves it to the backpack, so you should just use Axe.Unequipped imo.
I found it. There’s a weird case with my equipping system where it adds the tool to the player, then to the backpack, then back into the player (because just adding it the player didn’t automatically put it in the players had and forcing the tool to equip caused other issues. I don’t know why), so the animation was being played twice, essentially meaning that the script was only stopping half of what it needed to. I added a cooldown to the equip part so everything is good now
local Player = game.Players.LocalPlayer
local Animation = script.Parent.Holding
local Axe = script.Parent
local Animator = Player.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
local LoadedAnimation = Animator:LoadAnimation(Animation)
local Cooldown = false
Axe.Equipped:Connect(function(mouse)
if Cooldown == false then
Cooldown = true
LoadedAnimation:Play()
wait(.3)
Cooldown = false
end
end)
Axe.Destroying:Connect(function()
LoadedAnimation:Stop()
end)