How do I make an animation end differently depending on situation?

I have this simple animation

Ingame, it will have a hitbox, and so I’d like to make it so if it hits a player, it will continue into a grab and slam animation, but if it doesn’t it just misses and slides, how could this be possible?

Ok so, lets say that you hit.
The code will then go a little something like this:

punch:Play()
--hitbox mathematics
if gothit == true then
task.wait(1.23) --duration of punch
punch:Stop()
groundslam:Play()
task.wait(4.56) --duration of groundslam
groundslam:Stop()
end

Note that you first have to export, save and load the animations into the humanoid, store them in a variable and then do the

anim:Play()

Instead of using waits you can use animation events. When the initial punch is finished it will trigger an animation event that will tell the script to check if it didn’t hit anything, and if it didn’t hit anything it will pause the other animation and play the other otherwise it will continue with the first animation.

Any difference between using Animation Events and Special Keyframes?

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