I want to make an animation that has a character holding up food. However, there is an issue. Every time I play the animation, (animTrack:Play()) it plays regularly, but then also plays in reverse. I have tried to stop the animation whenever it reaches the position I wanted it to, however this doesn’t work for two reasons. First, after the animation track plays, it doesn’t read any line of code after it until the whole animation is finished (including going backwards). And second, animTrack:Stop() simply makes the animation go back into reverse to it’s original position. The other posts that I have seen on here also don’t help my issue.
This is the script that plays the animation:
local anim1 = script.Animation1
local humanoid = script.Parent.Humanoid
local animTrack1 = humanoid:LoadAnimation(anim1)
wait(14)
animTrack1:Play()
Video of character holding up food, and the animation being played in reverse:
Make it longer at the end, so it makes it easier know when to stop the script. You put the AdjustSpeed where you want to stop your animation, like after the animation players, wait 2 seconds then Add the AdjustSpeed
I think I came up with something?? it needs tweaking
since there are two actions for every track you’re trying to play, i have “moveTrack” and “idleTrack” so as to represent both actions’ current states.
local animate = function(direction)
moveTrack:Play(0.0001, 1, direction == "Up" and 1 or -1)
delay(moveTrack.Length * 0.99, function()
moveTrack:AdjustSpeed(0)
end)
moveTrack.Stopped:Connect(function()
moveTrack:Stop()
if direction == "Up" then
idleTrack:Play()
end
end)
end