Animation Not Playing Properly

For a while now, I’ve been trying to get some animations to load properly. I’ve set animation priority both in the animation editor and in the script. I’ve also tried using ‘:AdjustWeight()’. None of them have worked, or even slightly improved it. The animation is playing on the server, playing it on the client doesn’t work well, either. And there are no errors.

This is how it should play:

This is how it plays when I test:

no it is not a single animation, they are 4 separate ones

local Track = Instance.new("Animation")
Track.Name = AnimationName
local ID = Animations[AnimationName]["id"]
Track.AnimationId = "rbxassetid://"..ID
local Animator = Figure.Humanoid:findFirstChild("Animator")
local Animation = Animator:LoadAnimation(Track)
Animation.Priority = Enum.AnimationPriority.Action

I have a function in a module script that returns the animation. This is called by a script, where it plays the animation.

AttackAnimation:Play()
2 Likes

Do you have an idle animation if you sword (when the player is not walking)? And does your animation plays when clicked?

If so, maybe it is an interference with both animations. You can use

animation1:Stop()
animation2:Play()

Or something like that. Hope it helps :slight_smile:

1 Like

If it’s 4 separate animations, is there any wait time between them?

No, I don’t have an Idle animation specifically for the sword, the idle animation that you see is just a custom anim inputed into Roblox’s animation script. Yes the animation plays when clicked, but the animation does stop and wait before the next attack.

AttackAnimation.Stopped:Connect(function() -- when attack animation is stopped or finished playing
	Enabled = true -- allow to move on to next attack
end)
	
AttackAnimation:Play() -- play animation
Enabled = false -- do not allow to move on to next attack
AttackAnimation.Stopped:Wait() -- waits until animation is stopped
return 4 -- just because
1 Like

Maybe try to put

AttackAnimation:Play() – play animation
Enabled = false – do not allow to move on to next attack
AttackAnimation.Stopped:Wait() – waits until animation is stopped
return 4 – just because

Inside

AttackAnimation.Stopped:Connect(function()
Enabled = true
end)

So it should sound like this:

AttackAnimation.Stopped:Connect(function()
   Enabled = true -- allow to move on to next attack
   AttackAnimation:Play() -- play animation
   Enabled = false -- do not allow to move on to next attack
   AttackAnimation.Stopped:Wait() -- waits until animation is stopped
   return 4 -- just because
end)

Maybe it will work!

Or you can use instance.Changed to detect if any propertie was changed on the animation.

You can use as well If Enabled == true then and maybe it works.

It won’t because AttackAnimation.Stopped only fires when said animation is stopped or is finished playing. It cant stop or finish playing if I never say AttackAnimation:Play() outside of it, in addition, there is no point in Enabling and then Disabling without waiting.
also, I use something similar to if Enabled == true then:

if Enabled == false then return end

yes there is a wait between them, as i showed earlier, it waits until the animation is finished playing or is stopped

When I did animations in my game, I used something like:
wait(animationTrack.Length)
to wait the appropriate time between tracks (it essentially does the same thing as the event, but is a wait yield).

alright, i will try that out instead, thank you

1 Like

Unfortunately, that did nothing to help, but thank you for your feedback. (sry for the delay, I was AFK)

Alright, since it is a sword (obviously) you click to attack? How many times are you clicking? Once?

For each attack/animation, you click once. I am only clicking 4 times. But, even if I did click more than 4 times, it would register because the server is still waiting for the animation to end before accepting any more requests.

Right, I have made a sword script with a similar setup. My problem was the extra clicking interrupting the animation. You would ensure that this doesn’t interrupt with a boolean because I believe it would still try to run the animation again even if it waits. The wait just yields the code after the wait not any other clicks that incur.

edit:
Might I add, that the boolean be a debounce check. If you’re using a tool, you could even go as far as just checking the Tool.Enabled property for this.

Just surround your animation code with the debounce check and that might solve your issue? (Block any other unwanted clicks before animation finishes?)

Its not a debounce/wait issue the sword isnt even animated properly you can see it going sideways

My guess he didnt add the handle in the final animation and so only the body parts are animated

1 Like

No, I don’t believe it to be a debounce issue. When you say I didn’t add the handle to the final animation, I’m not really sure what you mean by that.

In whatever suite you use you get like a list of each part that is in your animation. Your sword handle has to be in that list or else it wont get animated. To check that open your 2nd 3nd or 4th animation in your editor and check if your sword is in that list. Your 1st animation seems to be animated correctly.

The part that controls the sword is listed in the animation. (The sword is one mesh part that is welded to a regular part that is connected to the right arm using a Motor6D).Screen Shot 2021-02-17 at 3.12.14 PM

Is that part animated though?.

Yes, everything there is animated. I put keyframes everywhere, I also import it to moon animator and then take export it. The only reason I’m showing it here is because it’s easier to see.