Help with stopping an animation

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

Alright, let us know if you get it fixed.

I have to go, I’ll try to fix it later.

1 Like

Alright, this is what I did. I made an RE and fired it to the client when the player was disequipping an item. The client then (in a different script in StarterCharacterScripts) stopped all animation tracks and called the reset function.

Thanks to @helperobc, @KhanPython, and @goldenstein64 for helping.

If you need help with this feel free to pm me, even if this topic is old.

Local script I added:

game:GetService("ReplicatedStorage"):WaitForChild("StopAnimation").OnClientEvent:Connect(function()
	local Player = game.Players.LocalPlayer
	if not Player.Character then return end
		local AnimationTracks = Player.Character.Humanoid:GetPlayingAnimationTracks()
	for i, v in pairs(AnimationTracks) do
		v:Stop()
	end
	local AH = Player.AnimationHolder
	AH.AnimationId = "rbxassetid://3703950890"
	Player.Character.Humanoid:LoadAnimation(AH):Play()
end)
9 Likes