Animation inconsistently stops at marker, sometimes bouncing back to its starting point

Hello everyone,

I’m struggling with a classic timing issue and would appreciate some advice on the standard, robust solution.

The Goal: I have an animation of a chest falling from the sky. When it lands, I want it to freeze permanently in its final pose.

The Problem: To achieve this, I placed an Event Marker named "EndPose" on the second-to-last frame of the animation. My script listens for this marker and sets the animation speed to 0.

However, this method is unreliable and only works about 50% of the time, as you can see in the video.

  • When it works: The animation freezes perfectly, and the chest stays on the ground.
  • When it fails: The animation plays, but instead of freezing, the entire model instantly snaps back to its original starting pose.

This feels like a classic race condition, where the animation sometimes ends before my script can react to the marker. I have already confirmed my model’s HumanoidRootPart is Anchored.

Here is my full script:

task.wait(2)

local character = script.Parent
local humanoid = character:WaitForChild('Humanoid')
local animator = humanoid:WaitForChild("Animator")
local chest = character:WaitForChild("Chest")

local particle = script.Parent.Parent:WaitForChild("Smoke Particle"):WaitForChild("Smoke Particle")
local animation = script:WaitForChild('Animation')

-- Sounds
local landingSound = particle.Parent:WaitForChild("Heavy Landing")
local fallingSound = particle.Parent:WaitForChild("Falling")
local chestSound = chest:WaitForChild("ChestSound")

local animationTrack = animator:LoadAnimation(animation)

-- This marker is for mid-animation effects
animationTrack:GetMarkerReachedSignal("TouchedGround"):Connect(function()
	fallingSound:Stop()
	landingSound:Play()

	particle.Enabled = true
	task.wait(0.2)
	particle.Enabled = false
end)

--[[
    -- THE UNRELIABLE PART OF THE SCRIPT --
    This is my attempt to freeze the animation. It seems to be in a "race"
    with the animation ending naturally, and it often loses.
--]]
animationTrack:GetMarkerReachedSignal("EndPose"):Connect(function()
	print("EndPose Triggered, attempting to freeze animation...")
	animationTrack:AdjustSpeed(0)
end)

-- Start the sequence
animationTrack:Play()
fallingSound:Play()
chestSound:Play()`

My Question:
How can I modify my approach to guarantee that the animation always freezes in its final pose? What is the method to solve this kind of timing-sensitive problem and make the result 100% reliable?

Thank you for your help!

You want the animation to play for each player when they join? or just once

The animation is meant to play each time an event fires, but for now I’m just testing the animation by itself to solve this issue.

Can i see the full script, i just need full context to understand

Yes, the code I posted is the entire script for now. In the future, this logic will be triggered by an event fired from a client.

To give you the full context you asked for, I’ve commented the script below to better explain my problem. The only issue I’m facing right now is the one I described.

Here is a step-by-step breakdown of the problem:

1. The Goal: I have an animation of a chest falling from the sky. When it hits the ground, it should stop moving and stay there.

2. The Initial Problem: When the animation finished playing, the entire chest model would instantly snap back to its original starting position high up in the sky.

3. My Attempted Solution: To fix this and make the chest stay on the ground, I added an Event Marker to the timeline in the Animation Editor. I named the marker "EndPose" and placed it on the second-to-last frame of the animation, right before it ends.

Here is a screenshot of my Animation Editor timeline showing the marker:

4. The Current, Unreliable Result: My script waits for this "EndPose" marker to be reached, and then it sets the animation’s speed to 0 to freeze it in place. However, this only works about half the time. The other half of the time, it fails, and the chest still snaps back to its origin in the sky. I don’t understand why it’s so inconsistent.

Here is my full script again, but this time with comments explaining my exact logic for solving the problem.

Yes, this is the full script I am using for testing this specific issue.

task.wait(2)

– Defining all the parts of my model
local character = script.Parent
local humanoid = character:WaitForChild(‘Humanoid’)
local animator = humanoid:WaitForChild(“Animator”)
local chest = character:WaitForChild(“Chest”)

– Defining sounds and particle effects
local particle = script.Parent.Parent:WaitForChild(“Smoke Particle”):WaitForChild(“Smoke Particle”)
local animation = script:WaitForChild(‘Animation’)
local landingSound = particle.Parent:WaitForChild(“Heavy Landing”)
local fallingSound = particle.Parent:WaitForChild(“Falling”)
local chestSound = chest:WaitForChild(“ChestSound”)

– Loading the animation
local animationTrack = animator:LoadAnimation(animation)

– This marker is for visual/sound effects when the chest hits the ground
animationTrack:GetMarkerReachedSignal(“TouchedGround”):Connect(function()
fallingSound:Stop()
landingSound:Play()

particle.Enabled = true
task.wait(0.2)
particle.Enabled = false
end)

–[[
THIS IS THE CRITICAL PART OF THE SCRIPT.
My goal is to freeze the animation right before it ends to prevent the model
from snapping back to its starting position. I do this by setting the speed to 0.
However, this only works about 50% of the time. The other 50%, it seems like
the animation ends before this code has a chance to run.
–]]
animationTrack:GetMarkerReachedSignal(“EndPose”):Connect(function()
print(“EndPose marker reached! Attempting to freeze the animation…”)
animationTrack:AdjustSpeed(0)
end)

– Starting the animation and sounds
animationTrack:Play()
fallingSound:Play()
chestSound:Play()`

Just realised the code isnt visible, there it is:

task.wait(2)

– Defining all the parts of my model
local character = script.Parent
local humanoid = character:WaitForChild(‘Humanoid’)
local animator = humanoid:WaitForChild(“Animator”)
local chest = character:WaitForChild(“Chest”)

– Defining sounds and particle effects
local particle = script.Parent.Parent:WaitForChild(“Smoke Particle”):WaitForChild(“Smoke Particle”)
local animation = script:WaitForChild(‘Animation’)
local landingSound = particle.Parent:WaitForChild(“Heavy Landing”)
local fallingSound = particle.Parent:WaitForChild(“Falling”)
local chestSound = chest:WaitForChild(“ChestSound”)

– Loading the animation
local animationTrack = animator:LoadAnimation(animation)

– This marker is for visual/sound effects when the chest hits the ground
animationTrack:GetMarkerReachedSignal(“TouchedGround”):Connect(function()
fallingSound:Stop()
landingSound:Play()

particle.Enabled = true
task.wait(0.2)
particle.Enabled = false
end)

–[[
THIS IS THE CRITICAL PART OF THE SCRIPT.
My goal is to freeze the animation right before it ends to prevent the model
from snapping back to its starting position. I do this by setting the speed to 0.
However, this only works about 50% of the time. The other 50%, it seems like
the animation ends before this code has a chance to run.
–]]
animationTrack:GetMarkerReachedSignal(“EndPose”):Connect(function()
print(“EndPose marker reached! Attempting to freeze the animation…”)
animationTrack:AdjustSpeed(0)
end)

– Starting the animation and sounds
animationTrack:Play()
fallingSound:Play()
chestSound:Play()`

I’m not a great animator, but I’ll try to still help.

When your script fails is it because the animation completed?

  1. Have you tried using animationTrack:Stop()?
  2. Try putting the GetMarkerReachedSignal AFTER animationTrack:Play() because ideally it’s better if you play the animation and then wait for the signal. (i think :sob:)

Don’t forget about roblox documentation: AnimationTrack Reference

Bad news,

Moving the :GetMarkerReachedSignal connections to be AFTER animationTrack:Play() has unfortunately not solved the problem. The exact same issue is still happening. :pensive_face:

The Problem Remains Unchanged: The animation is still completely unreliable.

  • About 50% of the time, it freezes correctly at the EndPose marker.
  • The other 50% of the time, it ignores the marker entirely and the model snaps back to its original starting pose.

Thats so weird because i feel like my script is very simple and should be functionnal, but its not, lol.

It’s been 2 days. Have you solved it yet?

I have a question about the critical part of the code.

– This marker is for visual/sound effects when the chest hits the ground
animationTrack:GetMarkerReachedSignal(“TouchedGround”):Connect(function()
fallingSound:Stop() -- Why do you stop and play sounds before the endpose? Since you want 
--to freeze the animation before it hits the ground, shouldn't you put this after the Endpose marker?
landingSound:Play()

particle.Enabled = true
task.wait(0.2)
particle.Enabled = false
end)

–[[
animationTrack:GetMarkerReachedSignal(“EndPose”):Connect(function() -- put this before the "TouchedGround"
print(“EndPose marker reached! Attempting to freeze the animation…”)
animationTrack:AdjustSpeed(0)
end)

– Starting the animation and sounds
animationTrack:Play()
fallingSound:Play()
chestSound:Play()`

Hey,

No, i’ve been searching for HOURS for why this doesnt work, for why my animation keeps going back to its original pose but nothing..:pensive_face:

And I initially placed the TouchedGround event first because I wanted the visual and sound effects to trigger exactly when the chest hits the ground, and then freeze the animation right after with EndPose. I changed their order and nothing changes, still does the same thing..

Tbh, the MAIN problem is that when the animation is done, the Chest goes back to its starting point where its HumanoidRootPart is. I just want the animation to not BOUNCE BACK to its starting point..

Honestly I would just give up and rewrite the code or try another method of detection. But it sucks when there’s a bug in the game that just remains unsolved after long hours of searching. Don’t worry, all devs have been thru it all. :sad:

Yeah I think thats what I will do, I will find another solution. Thanks for helping me!! :))