I want to play an animation when the player touches a part

Did this code. No error but the animation isn’t playing!

function onTouched(hit)
	local human = hit.Parent:findFirstChild("Humanoid")
	if human then
		local anim = human:LoadAnimation(script.Animation)
		anim:Play()
	end
end
script.Parent.Touched:connect(onTouched)

Put a print after this line and see if it prints, if it does, the animation itself has an issue.

It prints, so I think the animation is the problem, also the script needs a debound. This is the animation:

A friend made it for me but I don’t know what’s wrong! If you know, you can fix it for me or tell me what’s the problem? Thanks!

I have 2 ideas on why it doesn’t work

  1. The animation was made for the wrong rig (as in animated for r6 but attempted to be used for r15)
  2. You do not have access to the animation (He uploaded it to his profile so it wont work)
1 Like

The game is R6 but I think it’s the second problem. I’ll try message him to make the animation public. If that will work I will give you the solution mark. Thanks!

For you to be able to use the animation, he either has to send the animation to you via rig, or upload it to a group one of you own.

2 Likes