Help with stopping an animation

Maybe I could try a RunService.Heartbeat and check if the localscripts’s parent is nil then do that, but I’m not sure if it would work since destroy was called on it and its parent.

Didn’t work

The way this sounds to me is that the module/script isn’t seeing the holding animation being played on the player’s Humanoid.

Let me see if I can print it out

I’m still unsure by what the accessory means, is it not parented to the tool? Why not handle it all like this?

local Player = game.Players.LocalPlayer
local Tool = script.Parent -- Local Script
local Folder = Tool:WaitForChild("Folder") --- A folder where all animations are placed


Tool.Activated:Connect(function() -- Or equipped, whatever suits your case

 local example=Player.Character:FindFirstChild("Humanoid"):LoadAnimation(Folder.Animation)
 example:Play()

end)


Tool.Unequipped:Connect(function() -- Stop our animations
	local AnimationTracks = Player.Character.Humanoid:GetPlayingAnimationTracks()
	for i, v in pairs(AnimationTracks) do
		v:Stop()
	end
end)

https://gyazo.com/d6b21be6cd4740eaa2d07ddfb0bfd5f6

1 Like

I don’t want the player to be able to unequip the weapon

You could parent the weapon back to the Character as soon as it’s unequipped. There are multiple ways you may achieve this: Disabling unequipping or keys to unequip? - #12 by Kampfkarren

Also if you’re not planning for the tool to become unequipped why look into such problem?

1 Like

You could also disable the backpack.
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)

1 Like

The accessory isn’t much of a problem and it’s easier to position on the character.

Alright and were you able to see if the script that stops the animation was able to see animations playing?
Could put a simple print("Stopped an animation") in to see, don’t think there’s a way to pull the animation id from a track.

Just an alternative: There is a really useful plugin by @Maximum_ADHD That lets you position the tool as you want by the handle.

https://gyazo.com/616b708864f0979368ace11f159e1a9e

Select the tool, press on the plugin icon and you’re good to go

1 Like

I didn’t even know that existed, that could have saved me time months ago.

1 Like

Interestingly it only printed out the default idle animation.

Ok so try refreshing the Player variable by setting it again before you call up local AnimationTracks = Player.Character.Humanoid:GetPlayingAnimationTracks()

Reset it while it’s in the for loop? Wouldn’t that maybe crash it or something?

That’s in a loop? and just making sure is that in a module script as well?

The script in the original post is in a server sided function which is in a module script, it includes a for loop

Alright and that for loop is this or is there more I’m not seeing? v

	for i, v in pairs(AnimationTracks) do
		v:Stop()
	end
1 Like

I ran the script again and this time the wielding animation did get printed, also only that for loop. I’ve also tried stopping the animation on both the client and server.

1 Like

So it’s seeing the animation for wielding the sword, can you test it a few more times to make sure that it still sees it, if so it’s a completely different Issue than I had begun to think it was.

I think I have a method of fixing this, wait.

1 Like