Animation not fully playing

So I have an NPC that attacks the player but one problem is that the attack animation does not fully play. The priority is set to Action 4. I load the animation to the animator object but nothing seems to be working.

Client Script:

local swordAttackAnimationTrack

local function setSwordAttackTrackNil()
	if swordAttackAnimationTrack then
		swordAttackAnimationTrack:Stop()
		swordAttackAnimationTrack = nil
	end
end

local function playSwordAttackAnim(weapon)
	local attackAnimation = weapon:FindFirstChild("AttackAnimation")

	if tick() - swordAttackCurrentTime >= swordAttackCooldown and attackAnimation and attackAnimation:IsA("Animation") then
		swordAttackCurrentTime = tick()
		setSwordAttackTrackNil()
		swordAttackAnimationTrack = animator:LoadAnimation(attackAnimation)
		swordAttackAnimationTrack:Play()
	end
end

RemotesData.PlaySwordAttackAnimation.OnClientEvent:Connect(function(weapon)
	playSwordAttackAnim(weapon)
end)

Server:

RunService.Heartbeat:Connect(function()
    script.PlaySwordAttackAnimation:FireAllClients(weapon)
end)
1 Like

It would be nice if I had more context. How exactly is the animation not “fully” playing?

1 Like

The animation does not fully play at the beginning.

What it looks like:

Not fully playing:

Hmmm. I would personally handle animations like this on the Server Side. It could be that another animation is overlapping it.

1 Like

I have also tried doing this on the server but it doesn’t change anything.

I’m reading both scripts over again. Why are you repeatedly loading and playing the animation using RunService? If I’m understanding correctly, you could just have the animation play when the player attacks only.

Fixed but that doesn’t change anything.

set the animation blend time to 0

What is that? Where do I find that.

where you do swordAttackAnimationTrack:Play() do swordAttackAnimationTrack:Play(0)

I don’t understand why putting a 0 works.

So does it work? Or are you just asking me if it works

Yes it does but I don’t get it.

Well the blend time is the how long roblox smoothly interpolates the last animation to the current animation, its on 0.1 by default so it doesnt fully do the animation before smoothing it, setting it to 0 makes it do the animaton instantly

1 Like

Glad you found a solution! Sorry I wasn’t much of a help. I haven’t ever experienced this particular issue before so I didn’t quite know that that was the problem.

1 Like

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