Help with stopping an animation

Yes, I only use the Animation module to hold a table since it’s easier and I don’t need to change it in game. In the local script I use the animation id directly.

I tried wait(1) but it didn’t work.

1 Like

You could disable the server-sided animation player and keep the client animation player. I’m not too sure about that I think it’s a Tool behavior specifically. I’m going to try it out right now. Are you stopping the animations on both sides?

I already tried using only :Stop() and not the ResetAnimation, but that didn’t work.

So the holding animation still played during the wait(1) ?

Yes, it stopped for like 0.1 seconds due to the reset animation as it did before, then it moved back to the holding position.

I just tested this out. The animations do replicate to the server if you play it on the client so do consider handling that with the client side.

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()