Animation keeps looping forever

Hi all, I’m trying to use the default Roblox wave animation from /e wave and use it in my game.
I’m loading an animation track and then running it; the track is set not to loop yet it still loops after it finishes infinitely.

Originally this only occurred when I published the game and tested it with other people. The animation was running in a local script so I’m assuming that it only stopped for the local player and nobody else (I noticed that playing an animation in a local script will run it for everyone). However, when I moved the stop method to a regular server-side script, it refused to stop even for my own character.

I’ve tried forcibly stopping the track, destroying it, but it refuses to stop itself after it runs. I’ve looked on numerous threads on this issue before but the key difference was that the other authors were using their own animation that they had uploaded to Roblox themselves. Many of them were able to fix this issue by changing the loop setting on the Animation Editor or by reuploading it. But since I am using a default Roblox animation, I am pretty much unable to do any of that.

Any help with this bug would be appreciated. I would like to know any workarounds or different ways I can play animations if any exist; I can’t imagine that other scripters had never had this problem for such a core part of a game’s experience.

In a local script:

ReplicatedStorage.PlayAnimation:FireServer(char.Humanoid.Animations.Wave)

In a server-side script:

ReplicatedStorage.PlayAnimation.OnServerEvent:Connect(function(player, animation)
	local char = player.Character
	local humanoid = char.Humanoid
	local track = humanoid.Animator:LoadAnimation(animation)

	track.Priority = Enum.AnimationPriority.Action4
	track.Looped = false

	track:Play()
	
	track.Stopped:Connect(function()
		local animations = humanoid:GetPlayingAnimationTracks()
		for i, anim in pairs(animations) do
			anim:Stop()
			anim:Destroy()
		end	
	end)
end)

Try doing instead of track.Stopped to stop it manually

(Doing what exactly? Going to assume you mean track:Stop())

I did that previously, and it changed nothing. What I did notice however is that I believe that a different instance of a track appears when it loops after I tried running a print statement every time it stops, meaning that it stops once and does destroy itself, but somehow another instance of the animation is loading even though I never told it to.

Yea I meant track:Stop, sorry if it was hard to understand, and also could you show us the hierarchy of the Player?

Also try adding a GetDescendants() statement and see if there more thanone

try getting track.Length

local time = track.Length

track:Play()

task.wait(time)

track:Stop()

if you want to turn off the loop manually, just use this to insert animation (the one that is supposed to be in AnimSaves):

game:GetObjects("rbxassetid://animidhere")[1].Parent = workspace 

and yet this code can work with any uploaded animation, even with privated

Yes, that might work, but he already said that if you try to end the animation with track:Stop() it doesn’t work, so your scritp isn’t gonna work theoretically, even though ut was a good idea

1 Like

strange thing, but alright, maybe he can try using the second variant i put there

1 Like

Tried the second solution you put and running game:GetObjects() in a script isn’t possible, looking at the documentation. I can’t think of any alternatives to it (LoadAsset() does something completely different, yes? Don’t know why they would include it there…)

However, I just checked the server-side. It seems like the animation stopped there, but not on the client side…much like how running the animation in the client side stopped it for only the client side. I just tried firing a remote event to the client so it can stop the animation as well, but it’s unable to locate it for some reason, presumably because the parent is nil.

use console to use this command, not a script

just put the instance inside the AnimSaves of your dummy, go to animation editor and remove the loop

2 Likes

Ahh okay. I suppose I have to reupload the animation then? Thanks for solving by the way!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.