Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to play an animation when the npc touches player?

Hello guys, I have a zombie. you know zombies hits with their hands so, i gave them a sword they still hit with their hands but i just want to add a swing animation to zombie so i think when i add an animation to sword it wont play. How can i make the attack animation for it.

For example:

When zombie hit, animation plays.

I think it's pretty simple but i don't know how to make it please help me.

1 answer

if you did not make the animation then follow these steps

  1. go to the plugins tab
  2. make a rig by clicking rig builder if you havent
  3. when you have your rig click animation editor
  4. click the rig that you made
  5. make animation

put this in your script

local zombie = script.Parent
local zombieSwing = Instance.new("Animation", zombie)
zombieSwing.AnimationId = "rbxasset://00000000 --put your animation id here (replace the zeros)
local zombieHum = zombie:FindFirstChild("Humanoid")

local zombieSwingTrack = zombieHum.LoadAnimation(zombieSwing)

and then put this where you want to play the animation

zombieSwingTrack:Play()

8 comments

0

i got that but how can i make the zombie check the players touch?

0

wdym by that like the sword?

0

yeah.

0

i want to make the zombie play the animation when a player touches it.

0

not acually sure oof i found a question like that somewhere i try and dig it out for you

0

i think i can check it with a part but it wont play the animation after it.

0

Not working, i did it with a part

0

its working but the npc is not moving its parts but animation plays, i tested it when the npc is moving he get stucked but nothing moved from his body parts.

This discussion is preserved as it was. New answers, comments, and votes are closed.