Stop Animation at 80% of it's progress

Basically, I would like to detect when an animation is on 80% of its progress until being stopped and stopping it, how would I do that?

You can try something like this:

local human
local animation
local track = human:LoadAnimation(animation)

track:Play()

while wait() do
	local progress = math.floor((track.TimePosition / track.Length) * 100)
	if progress >= 80 then
		track:Stop()
	end
end
1 Like

80% sounds like an arbitrary number that will change later. For a more robust setup, use Animation Events, then stop the animation when it reached the marker with this command. I use this for parrying.

AnimationTrack:GetMarkerReachedSignal (roblox.com)

1 Like