I’m trying to make it so my NPC is able to move using the Humanoid:MoveTo() function and make it have a walking animation, and I don’t know how to do this. Any help would be appreciated.
4 Likes
Add 2 Animations in to your script and make one an Idle the other Walk For R6, I use:
Idle - http://www.roblox.com/asset/?id=180435571
Walk - http://www.roblox.com/asset/?id=180426354
In the controlling script use the following to load the animation to the NPC, assuming your NPC is defined as npc
:
local newAnimator = Instance.new("Animator")
newAnimator.Parent = npc.Humanoid
local npcWalk = npc.Humanoid:WaitForChild("Animator"):LoadAnimation(script.WalkAnim)
local npcIdle = npc.Humanoid:WaitForChild("Animator"):LoadAnimation(script.IdleAnim)
Then after your MoveTo: event you just play the animation:
npc.Humanoid:MoveTo(randomPos)
npcWalk:Play()
npc.Humanoid.MoveToFinished:Wait()
npcIdle:Play()
3 Likes