Why is this animation not playing correctly?

https://gyazo.com/172a71cd1adf924e9267365a741479c9

In the video above it shoes that when the NPC touches the part it doesn’t play the wave animation how it normally should. I got the animation ID out of the Animation script that is located in your character when you play. This is the same when I tested it myself.

local part = script.Parent

local id = "rbxassetid://507770239"
local debounce = true

part.Touched:Connect(function(hit)
	if debounce == true then
		debounce = false
		
		local char = hit.Parent
		local hum = char:WaitForChild("Humanoid")

		local animation = Instance.new("Animation")
		animation.Name = "LocalAnimation"
		animation.AnimationId = id

		local animtrack = hum:LoadAnimation(animation)
		animtrack:Play()
		debounce = true
	end
end)

try this

local part = script.Parent

local id = "rbxassetid://507770239"
local debounce = true

part.Touched:Connect(function(hit)
	if debounce == true then
		debounce = false
		
		local char = hit.Parent
		local hum = char:WaitForChild("Humanoid")

		local animation = Instance.new("Animation")
		animation.Name = "LocalAnimation"
		animation.AnimationId = id

		local animtrack = hum:LoadAnimation(animation)
		animtrack:Play()
        animtrack.Stopped:Wait()
		debounce = true
	end
end)

Hey, it gives me the same result

1 Like