Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to do something while an animation is playing?

Asked by
Mystdar 352 Moderation Voter
9 years ago

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.

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

1 answer

Log in to vote
0
Answered by 9 years ago

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

Ad

Answer this question