Im currently making a combat system. I have damage and animation in the combat system so far.
A problem is that the dummy gets damaged before the animation gets finished.
So what I did is that I added a wait() after the animation plays, after some time, it will do the damage part of the system. So it gives the illusion that the dummy is getting damaged when the punch actually hits it.
Is this a effective way to do this?
The blue is the animation and the wait, the red is the damage part.
loadanim.Stopped:Wait() actually waits for the animation to finish. More info about AnimationTracks can be found here.
PS: you could also use AnimationTrack.KeyframeReached("keyframe_name"):Wait() if you want the damage to be done during a specific keyframe while the animation plays.
This is an effective way of doing this, but instead of magnitude I would really think about making a hitbox that is a part with a .Touched event on the client side and having the damage fire to the server.
Not at all, it would technically be way more laggy to loop through all of workspace and check every players position to your position every time you punch.