Is it possible to adjust the speed of animation track on its last keyframe to 0?

I’m trying to make an animation that starts with an animation but freezes on the last keyframe as the idle animation with a tool but I can’t find out how to make it freeze.

I’ve tried putting it on looped which has made it worked but its extremely imperformant as it runs forever and I just want an idle animation.

I tried using animation events or checking when the animation stopped but it was very delayed.

I thought of using the Animate script you find in character but I’m not sure that is efficient for what I’m trying to achieve.

I also copied the last frame and moved it up the track to ensure it wasn’t because it was ending too shortly but it didn’t change.

Any other options?

Main Code:

	character.ChildAdded:Connect(function(tool) -- wait for tool on client
		if tool:IsA("Tool") then
			if tool:FindFirstChild("BodyAttach") and rightArm then
				rightArm.ToolGrip.Part1 = tool.BodyAttach
			end
			local idleTrack = animations[tool.Name.."Idle"]
		
			if idleTrack then
				idleTrack:GetMarkerReachedSignal("End"):Once(function()
					print("End")
					idleTrack:AdjustSpeed(0)
				end)
				idleTrack:Play()
			end
			local c = Tools.Trigger(tool)
			table.insert(connections,c)
		end
	end)

You could try setting the position of the animation in addition to freezing it:

-- Make sure the track is going when you freeze it
if not idleTrack.IsPlaying then
    idleTrack:Play()
end
-- Make sure the track is at the right spot
idleTrack.TimePosition = idleTrack.Length -- Might need to do - 0.00001 or something
-- Freeze the track
idleTrack:AdjustSpeed(0)

A possibly better option is just to copy the last frame into a new looped animation and play that animation once the equip animation is done. Probably the intended way of doing this.

				idleTrack:GetMarkerReachedSignal("End"):Once(function()
					print("Ended")
					local keyFrame = idleTrack:GetTimeOfKeyframe("End")
					idleTrack.TimePosition = keyFrame
					idleTrack:AdjustSpeed(0)
				end)
				idleTrack:Play()

This my attempt at using that. I try to get the keyframe position which is the animation event but it still seems to freeze in a halfway position of the idle animation.

When I made this animation, this is the first thing that happened. The only difference is, is that last time it only played one loop and now its playing forever.

Expectations:

Reality:

It seems to be locking in place for some reason into this position, this is me automatically stopping it after playing it.

No matter the number of the time position, it locks into this place.

Found it, all I had to do was set the animation priority to action

1 Like

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