Play is not a valid member of Animation

Basically I am playing animation on humanoid using server script but I am getting this error:


I know this error mostly pops out when you try to play animation track instead of an animation, but thats not the case here. I dont know what is the issue and any help will be appreciated.
my code:

local parryA = script.Parent.parry
--I have humanoid defined elsewhere but copypasting whole script would cause confusion, but I can assure you that the humanoid IS defined as it should be
local parryAnimation = humanoid:LoadAnimation(parryA)
parryAnimation:Play()

explorer photo:
image

try using Instance.new(“Animation”)

Try this, although I have no idea why yours didn’t work:
local parryA = script.Parent.parry.AnimationId

have you attempted using humanoid.Animator:LoadAnimation(anim) and then using the :Play() method on it?

I tried:

local parryA = Instance.new("Animation")
parryA.AnimationId = "rbxassetid://10180376621"
parryA.Archivable = true
parryA.Parent = humanoid.Parent
local parryAnimation = humanoid:LoadAnimation(parryA)
parryAnimation:Play()

but still the same error

I did but I still get the same error

I tried but got this error instead:
image

Mind showing us properties for parry?

are you sure the humanoid is a valid object?

1 Like

Also, could you show us how you defined humanoid?

1 Like

image

yes, becasue humanoid:takedamage() function works correctly

I am using “RayCastHitbox” libary for hitbox function, and I use this function: hitBox.OnHit:Connect(function(hit, humanoid)

You should use parry.AnimationId
LoadAnimation(parry.AnimationId)

still getting this error:
image

1 Like

On which line is the error occurring, the :Play() or the LoadAnimation

Ok you don’t need to create an entirely new Animation if its already there. What you were doing before is perfectly fine. Try this instead.

local ParryA = script.Parent:WaitForChild("parry")
local Humanoid = define humanoid.
local Animator = Humanoid:WaitForChild("Animator")

local ParryAnimation = Animator:LoadAnimation(ParryA)

ParryAnimation:Play()

Thanks to you I noticed that the line of error showed one line BELOW the animation, where I was playing a sound, I have noticed that I have also a sound with name “parry” under the parent, I have renamed it and it works, thank you

nvm I just noticed that the animation still DOESNT play, but I got no error from the script

I tried but the humanoid wont play the animation, but now I get no error