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

Trouble Animating an NPC rig that contains a humanoid?

local animation = Instance.new('Animation')
animation.AnimationId = "http://www.roblox.com/Asset?ID=2769812861"

local animTrack = Humanoid:LoadAnimation(animation)
animTrack.Play()

I asked a question about this earlier but I feel that I might have asked it wrong... I created an rthro rig and tried to animate it. I successfully created and uploaded the animation, but I am having issues activating it. I placed this script into the rig (no where in specific), titled "Dummy," and it isn't really working... Are there any steps I am missing? Did I write the code wrong? Does the script need to be in a different place? Any help is welcome. Thank you.

Also it might be important to note that I used this link to create this: http://wiki.roblox.com/index.php?title=Animations#Using_Animation_in_Games

3 comments

0

Have you defined "Humanoid?"

0

If you mean write it out as a variable, then no.

0

I posted all I wrote in that code block.

1 answer

Sorry, didn't see you wanted to animate the NPC. To animate the NPC it needs to have 2 things:

  1. Animation
  2. Humanoid

Try using this:

local humanoid = script.Parent:WaitForChild("Humanoid") --Finds the Humanoid
local animTrack = hum:LoadAnimation(script:FindFirstChildOfClass("Animation")) --Finds your Animation inside the script (FindFirstChildOfClass) (The ClassName of Animation is "Animation", so it specificly finds the Animation itself.. nothing else.)

animTrack.Looped = true --You can make it looped.
animTrack:Play() --Play the Animation

Note: This script should be a ServerScript inside your NPC. Your Animation should be inside the script and it needs to have the AnimationID.

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