I am currentely working on a Tower Defense game in roblox, but I have been struggling with making the NPC walk animations work. Here is the code I am using (it is inside starterplayerscripts);
local function animateMob(object)
local humanoid = object:WaitForChild("Humanoid")
local animFolder = object:WaitForChild("Animations")
if humanoid and animFolder then
local walkAnimation = animFolder:WaitForChild("Walk")
if walkAnimation then
local animator = object:WaitForChild("AnimationController").Animator
local walkTrack = animator:LoadAnimation(walkAnimation)
walkTrack:Play()
walkTrack.Looped = true
end
else
warn("No humanoid or aniamtion for ", object.Name)
end
end
workspace.Mobs.ChildAdded:Connect(function(child)
animateMob(child)
print("Animation Playing")
end)
The print statement works, but the animation just doesn’t play.