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)
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.
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
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.