if executeOnKill and #dyingTargets > 0 and not killAnimationExecuted then
killAnimationExecuted = true
table.sort(dyingTargets, function(a, b)
return a.humanoid.Health > b.humanoid.Health
end)
local targetData = dyingTargets[1]
local targetChar = targetData.char
local targetHum = targetData.humanoid
local killerRoot = attackerChar:FindFirstChild("HumanoidRootPart")
if killerRoot and targetChar:FindFirstChild("HumanoidRootPart") then
targetChar:SetPrimaryPartCFrame(killerRoot.CFrame)
end
local killerHum = attackerChar:FindFirstChildOfClass("Humanoid")
local killerAnimId = attackerChar:GetAttribute("KillerKillAnim")
local targetAnimId = targetChar:GetAttribute("killedTargetAnim")
local stopDuration = 0
if killerHum and not killerHum:FindFirstChildOfClass("Animator") then
Instance.new("Animator", killerHum)
print("New")
end
if targetHum and not targetHum:FindFirstChildOfClass("Animator") then
Instance.new("Animator", targetHum)
print("New")
end
local killerTrack, targetTrack
if killerHum and killerAnimId then
local anim = Instance.new("Animation")
anim.AnimationId = killerAnimId
killerTrack = killerHum:LoadAnimation(anim)
killerTrack.Priority = Enum.AnimationPriority.Action
killerTrack:Play()
stopDuration = math.max(stopDuration, killerTrack.Length)
end
if targetHum and targetAnimId then
local anim = Instance.new("Animation")
anim.AnimationId = targetAnimId
targetTrack = targetHum:LoadAnimation(anim)
targetTrack.Priority = Enum.AnimationPriority.Action
targetTrack:Play()
stopDuration = math.max(stopDuration, targetTrack.Length)
end
task.spawn(function()
task.wait(stopDuration)
Util.stop(attackerChar, stopDuration) -- NOTE: Since stop only fixes the HumanoidRootPart, it shouldn't affect the animation. Thanks
Util.stop(targetChar, stopDuration) -- NOTE: Since stop only fixes the HumanoidRootPart, it shouldn't affect the animation. Thanks
if killerTrack then killerTrack:Stop() end
if targetTrack then targetTrack:Stop() end
pcall(function()
targetHum:TakeDamage(damage)
Ragdoll.doll(targetChar)
end)
end)
end
attacker (Killer) animation plays just fine, but for some reason the Target’s animation doesn’t play. I’ve checked the logs, and there are no errors or warnings. I need someone to help me.