Animation play and not stop when touch part

Hi, I’m trying to make a script which plays an animation when you touch a part and doesn’t stop. However, when I move the animation stops playing. Does anyone know how to fix this?

this is my code:

function onTouched(hit)
	local human = hit.Parent:findFirstChild("Humanoid")
	local anim = human:LoadAnimation(script:FindFirstChild("Animation"))
	anim.Looped = true
	anim.Priority = Enum.AnimationPriority.Action
	if human then
		anim:Play()
	end
end

script.Parent.Touched:connect(onTouched)

Thanks

anim.Looped = true
^ This will cause the animation to loop, try changing it to false.


It does the same thing. I’m trying to make it so this animation will just keep repeating.

huh, if the animation type is action, it should work…try changing it manually

What do you mean try changing it manually?

You need to set the Animation priority to be an action

This is easily done with
[animation variable].AnimationPriority = Enum.AnimationPriority.Action

This makes it override the default roblox walking animation

Screen Shot 2022-01-30 at 11.05.03 AM
in the animation tab you can change it manually and stuff

Aa thanks it works now! I appreciate it