I m trying to make an enemy NPC load a punch animation when he is close to the player. So to decide when the NPC start punching, I put a part all around the NPC and when the player touched it is supposed to load the animation.My problem is that the animation constantly plays when the player touch the part. So I want to know how to pause between each time the animation play? or if someone can shows me a better way to make the NPC attack it would be appreciated ! Here is my script
local hum = script.Parent.Parent:WaitForChild("Humanoid") local anim = hum:LoadAnimation(script:FindFirstChildOfClass("Animation"))
local function onTouch(hit) if (hit.Parent:FindFirstChild('Humanoid')~= nil) then anim:Play() wait(1) end end
script.Parent.Touched:Connect(onTouch)

1 comment
Format your code by pressing the lua button in text editor.