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

How to play my animations on an NPC?

How can I get my custom model NPC to play the animation I made for it?

I read the wiki, but I still don't get what I'm really suppose to do. I feel like it doesn't give me enough information for me to figure out what I'm suppose to do.

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

local animTrack = Enemy:LoadAnimation(animation)
	animTrack:Play()

local animController = Instance.new("AnimationController")
local animTrack = animController:LoadAnimation(animation)
	animTrack:Play()

That's what I have, but I don't know what the problem Is...? I rigged the NPC together with the Motors as well.

There's a picture of what I have on the model

3 comments

0

gyazo.com/17ed4c674b81b57737571638acaf3eda

0

Thats the picture^^^

0

Let me know if you need any more help!

1 answer

✓ Accepted answer

First of all, always use rbxassetid:// when dealing with a Roblox asset, except with Package Id's and with images built-in to Roblox.

Next, let's talk about Animations. Animations need to be loaded into either a Humanoid or an AnimationController in order to run. If you are using an NPC, which has a Humanoid, you should be using the Humanoid. Let's also make sure that your Animation is a descendant of the workspace.

-- @author DeAigle
-- Runs an animation in an NPC

local NPC = workspace.NPC -- Define this
local Humanoid = NPC.Enemy

local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://695230026"
Animation.Parent = Humanoid

local Track = Humanoid:LoadAnimation(Animation)
Track:Play()

Great-looking model, by the way. Good luck!

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