I made an animation of an NPC in my experience getting out of his bed, but when the animation finishes, he teleports right back into his bed. How can I make it stay at the last frame once it finishes? Thanks
You could try calling Animation:AdjustSpeed(0)
right before it actually finishes to pause it.
I would do something like this
local track = humanoid.Animator:LoadAnimation(animation)
track:Play()
task.wait(track.Length * 0.99)
track:AdjustSpeed(0)
I haven’t tested it but it should work
EDIT: this is the first post ive seen use “experience”
Well it’s because my game is more a real-life simulation instead of a game and as Roblox and Apple define it, a game goes on forever while an experience is only played once.
if it dont work try using task.wait(track.Length * 0.8)
(it worked for me with 0.8)
Sorry for necro, couldn’t find anything anywhere that answered this question though.
If anyone else happens upon this thread, something I found that doesn’t use task.wait is:
animationTrack.Stopped:Connect(function()
animationTrack:Play(0, 1, 0) --Will restart the track at the beginning, fadeIn 0 so it immediately has appropriate weight, speed 0, so that it pauses
animationTrack.TimePosition = animationTrack.Length --Set to the last key in the sequence
end)
Edit - It’s come to my attention the reason that works is because it gets Stopped / restarted at track.Length every single frame. For one that doesn’t see below:
animationTrack.Stopped:Connect(function()
animationTrack:Play(0, 1, 0) --Will restart the track at the beginning, fadeIn 0 so it immediately has appropriate weight, speed 0, so that it pauses
animationTrack.TimePosition = animationTrack.Length - .000001 --Something small enough that it's not truly at the end, causing a reset
end)