Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to do something while an animation is playing?

This is how you play an animation:

local animation = Instance.new("Animation")
	animation.AnimationId = "http://www.roblox.com/Asset?ID=144884906"
	 
	local animTrack = Humanoid:LoadAnimation(animation)
	animTrack:Play()

Would I put something like:

while animTrack:Play() do

Thanks.

1 comment

0

You should be able to do stuff as the animation is playing. I don't think the :Play() method yields the calling script.

1 answer

I agree with Tkdriverx. You should use the KeyframeReached event for doing something. Something like this, maybe?

animTrack.KeyframeReached:connect(function(keyframeName)
if keyframeNAme ~= "End" then
--do stuff here
end
end)

KeyframeReached wiki link

This discussion is preserved as it was. New answers, comments, and votes are closed.