Hello! I’m currently trying to get a reaction animation when an enemy humanoid is punched, for the most part, it works, but for some reason, it occasionally spits out ’ LoadAnimation requires an Animation object’, even though there should be a humanoid there. It is really puzzling me because it works sometimes but then doesn’t the next. All of the animations are preloaded and work, its just this part of the script. It is also using R6. (This is my first post on the devforum so please give me feedback) Thanks!
local anims = {
animations:WaitForChild("punch1"), animations:WaitForChild("punch2"), animations:WaitForChild("punch3"), animations:WaitForChild("punch4"),
}
local eanims = {
enemyanims:WaitForChild("enemypunch1")
}
local limbs = {
"Right Arm", "Left Arm", "Right Arm", "Right Arm"
}
hitbox.Touched:Connect(function(hit)
if hit:IsA("BasePart") then
if not hit:IsDescendantOf(char) then
local enemyhum = hit.Parent:FindFirstChild("Humanoid")
local enemyroot = hit.Parent:FindFirstChild("HumanoidRootPart")
if enemyhum and enemyroot then
hitbox:Destroy()
enemyhum:TakeDamage(damage)
local react = enemyhum:LoadAnimation(eanims[count])
react:Play()
end
end
end
end
end)
If you need the whole script i can add it, i just thought it was quite large and chunky so i snipped it a bit. (this is also due to lack of experience on the developer forums)