[SOLVED] Animation Playing On Damage Taking

Maybe I might need “LoadAnimation()” in the script, but I’m not sure where to put it.

So a few things with your latest code:

  • You need to load the animation into the Humanoid - CTRL + F “Playing Animation in a Player Character”
  • Your animation link has two rbxassetid://
  • Your .Changed function will fire when your Player also heals
  • I could be mistaken, but iirc .Changed in a client script can be finicky/not work

Oh, PFFT, I didn’t notice the second rbxassetid.

1 Like

Aaaaand, now I’m stuck, I don’t know where to put this.

Assign that highlighted text to a variable name, then change the function to play that variable name.

I just did that, and it’s still not working. This is dumb, I can’t seem to nail this script.

Your animation is called “youranim”, not “animation.”

1 Like

That’s where I get confused.

Put “youranim” here:
image

There’s nothing in your script with the variable name “animation.” There’s just “youranim.”

Done and done.

Output: image

Can you post a pic of your code? I think you may’ve used a . instead of a : for your Play function.

I believe you aren’t loading the AnimationTrack, or what @cloakedyoshi said.

1 Like

You’re still trying to play the Animation object. You need to create and refer to this as a variable instead:
image

1 Like

Here’s some fixed code:

local Humanoid = script.Parent.Humanoid

local youranimation = Instance.new('Animation')
youranimation.AnimationId = 'rbxassetid://' -- please note that other users cannot load your animations, so there is no need to hide it.
youranimation.Priority = Enum.AnimationPriority.Action

local AnimationTrack = Humanoid:LoadAnimation(youranimation)

Humanoid.Changed:Connect(function(property)
	if property == 'Health' then
		AnimationTrack:Play()
	end
end)

Let me try that.

It didn’t work!

What’s the error. Just tested and it works.

Is it possible that your animation’s priority value is too low?