I'm creating an enemy were if you hit it, and wait a second, it would block, but since I'm new to scripting (blame my mind since I forget most of the stuff when watching tutorials and reading tutorials in the roblox wiki, rewatching(rereading) can be a pain but I still forget)
Basically if you hit the enemy(npc, not player) and wait a second, the enemy would block and play an animation (the blocking animation.) but nothing works.
script:
local anim = script.Block local function onHealthChanged() wait(0.5) anim:Play end
idk if this will work if not sorry for wasting your time but here goes nothing:
local npc = --your npc here local anim = script.Block local function onHealthChanged() wait(0.5) anim:Play() end npc:WaitForChild("Humanoid").HealthChanged:Connect(onHealthChanged)
again sorry if it doesnt work but at least i tried
*Note that the npc variable must be an instance that is a parent to Humanoid.
If your NPC does not have Humanoid in it use this script
local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://3410088748" -- animation ID local animController = Instance.new("AnimationController", script.Parent) local animTrack = animController:LoadAnimation(anim) local function onHealthChanged() wait(0.5) animTrack:Play() end
if your NPC does have Humanoid in it use this script
local char = script.Parent local humanoid = char.Humanoid local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://3410088748" -- animation ID local p = humanoid:LoadAnimation(anim) p.Priority = Enum.AnimationPriority.Action local function onHealthChanged() wait(0.5) p:Play() end --[[while wait(2) do onHealthChanged() end]]