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

How do I animate an NPC with an AnimationController?

I have the warrior moving to a certain position, but he is not being animated. I just used the walking anim from my player. I welded all the parts of him too.

local warrior = script.Parent.Parent

--Animations
local walkAnim = warrior.Anims.Walk

--Variables
local animTrack = nil
local canPlay = true

function playWalk()
	if canPlay then
		canPlay = false
		animTrack = warrior.AnimationController:LoadAnimation(walkAnim)
		wait()
		warrior.Humanoid:MoveTo(game.Workspace.walkPart.Position)
		animTrack:Play()
	end
end

wait(3)

playWalk()

2 comments

0

Perhaps try connecting your rig w/ motors

0

I only use AnimationController on Objects. I use normal animate on npcs

1 answer

This is a hard one.

Now here is a script to put the animation to a specific spot.

1-- Assuming your NPC has a humanoid... 2 script.Parent.Humanoid:MoveTo(0, 0, 0) -- Replace the 0's with desired coordinates. (X, Y, Z)

You can put a wait (number) in there so your NPC can be walked when timed.

You can also use animation editor and get the animation in the script, for example.

01-- Assuming your NPC has a humanoid... 02 script.Parent.Humanoid:MoveTo(0, 0, 0) -- Replace the 0's with desired coordinates. (X, Y, Z) 03 wait (3) -- 3 is the example number... 04-- Drag the animations in the script. 05-- Sooner or later test the game

(If It did not work sorry.)

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