Animation not playing correctly

I’m sure Scripting Support gets a lot of posts regarding animations not working, but if I recall there are many ways to load animations.

I’m not sure what’s gone wrong here, but I’ve uploaded an animation and uploaded it to my profile, so I’m the creator:

		v.btn.MouseButton1Down:Connect(function()
			local animTrack = plrHumanoid:LoadAnimation(v.Animation)
			local getAnimTracks = plrHumanoid:GetPlayingAnimationTracks()
			
			if animDebounce == false then
				animTrack:Play()
				game.ReplicatedStorage.animGuiEvents.createSignals:FireServer(false)
				animDebounce = true
			elseif animDebounce == true then
				for i,track in pairs(getAnimTracks) do
					game.ReplicatedStorage.animGuiEvents.createSignals:FireServer(false)
					track:Stop()
				end
				animDebounce = false
			end

But when I click “Dress Right”, the animation is meant to stay playing until I click it again, here it just plays once then stops on it’s own:
https://i.gyazo.com/e4e257d620f25e46ebd41ea617268262.mp4

Did you make sure the looping property of the animation is set to true? You can do that in animation editor by pressing “toggle looping animation”.

If you want to keep it playing the reason isn’t the scripting
It’s the animation having its loop setting turned off.

Anyway, the script could be better in some areas, but regarding the issue other than that ^^ Thats usually the culprit.

Surely if I looped it, the arm would continue going up and down?

Could you send a preview of the animation? It really depends on how you animated it.
How I usually do mine is just 1 or 2 keyframes, My expertise isn’t in animation but that’s my basic understanding of what you’re trying to do.

Example of what I did and it works fine.

Another method is you can freeze the animation by adjusting its ‘AdjustSpeed’ function in the Animation API. Thing is you would need the exact keyframe on which it would stop/freeze.

https://developer.roblox.com/en-us/api-reference/property/AnimationTrack/TimePosition

Refer to this article on Anim:AdjustSpeed()

https://i.gyazo.com/48cc43e88d18ab505a9e48b888dea08c.mp4

Roblox will do the interpolation from the first to the second keyframe on its own, which makes the first part of your animation obsolete. Try deleting the first keyframe of the animation and setting the looped property to true.

1 Like

The :Play() function of the AnimationTrack actually accepts 3 parameters: fadeTime, weight and speed. Try setting fadeTime to the time you want the arm to take to reach its final position. (e.g. animtrack:Play(1.5))

More information: AnimationTrack | Roblox Creator Documentation

2 Likes

Thanks, this worked for all my animations
Thanks @DerryOrigin for helping too

What is this delay when i put Play:(0.3) ?

FadeTime is the duration of time that the animation’s weight should be faded in for in seconds. Hence 0.3 seconds.

1 Like

This FadeTime can be used in Stop:() too?, for a slowly decadence

Yes, refer to: AnimationTrack | Roblox Creator Documentation

1 Like