Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to fix NPC's won't play their walk animation in my tds?

Asked by 1 year ago
Edited 1 year ago

This local script should apply a walking animation to all of the enemies in my TDS game:

local function animateMob(object)
    local humaniod = object:WaitForChild("Humaniod")
    local animationsFolder = object:WaitForChild("Animations")

    if humaniod and animationsFolder then
        local walkAnimation = animationsFolder:WaitForChild("Walk")
        if walkAnimation then
            local animator = humaniod:FindFirstChild("Animator")
            local walkTrack = animator:LoadAnimation(walkAnimation)
            walkTrack:Play()
        end
    end
end

workspace.Mobs.ChildAdded:Connect()

However, it doesn't work and I've made multiple attempts at this. The local script is in StarterPlayerScripts and in ServerStorage. I have a folder called "Mobs" with all of the different enemies in it. The humanoids for all of the mobs have Animators and I added a config folder with the walk animation in it.

Answer this question