I'm trying to make a simple walking animation for an NPC. I've looked through many other models in the toolbox and tutorials to see if I could figure it out, but have had no luck.
It's a custom rig (dog) and uses a humanoid part. I was able to make it wander around, but can't start and stop the walking animation when it's needed. The closest I've gotten so far is a constant animation that never stops which is the following script:
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local animation = hum:LoadAnimation(script.Animation)
animation:Play()
The script for the wandering is the following:
local CurrentPart = nil
local MaxInc = 16
function onTouched(hit)
if hit.Parent == nil then
return
end
local humanoid = hit.Parent:findFirstChild("Humanoid")
if humanoid == nil then
CurrentPart = hit
end
end
function waitForChild(parent, childName)
local child = parent:findFirstChild(childName)
if child then
return child
end
child = parent.ChildAdded:wait()
if child.Name==childName then
return child
end
end
end
local Figure = script.Parent
local Humanoid = waitForChild(Figure, "Humanoid")
local Torso = waitForChild(Figure, "Torso")
local Left = waitForChild(Figure, "LeftLeg")
local Right = waitForChild(Figure, "RightLeg")
Humanoid.Jump = true
Left.Touched:connect(onTouched)
Right.Touched:connect(onTouched)
while true do
wait(math.random(2, 6))
if CurrentPart ~= nil then
if math.random(1, 2) == 1 then
Humanoid.Jump = true
end
Humanoid:MoveTo(Torso.Position + Vector3.new(math.random(-MaxInc, MaxInc), 0, math.random(-MaxInc, MaxInc)), CurrentPart)
end
end
If any of you know how to make the walking animation activate for a walking animation, it would be greatly appreciated!

5 comments
Watch this video - https://www.youtube.com/watch?v=t4hpa9KR-P8
Judging from the comments on that video, the information is outdated and doesn't work.
I recommend just modifying the player's animation script and just cut out everything you don't need and making it simpler.
In a server script, when the player joins, there is a script inside the char called Animate. It contains all the values for animations. Choose walk or run for example and inside the value, there should be an animation object, so change the property of it to your anim id. Format: "rbxassetid://ID HERE"
@SteamG0D --My animation only has four parts and 3 key frames-- @IceyTazeForLife --I did as you said and copied the Animate to my model. I changed just the walk to animation id, then just the run, both, and lastly all of them. Anytime the model moves, it still has no animation. I wrote in the format you typed and this: "http://www.roblox.com/asset/?id=ID HERE"