Mesh animation not playing

I made a mesh animation for one of my monsters, but whenever I go in game It doesn’t show even in the studio. I’m thinking that the problem is the script.

local h = script.Parent:WaitForChild("Humanoid")
local a = h:LoadAnimation(script:FindFirstChildOfClass("Animation"))
a.Looped = true
a:Play()

I went on devforum to try and find a solution but I never found any answers. I also went on YouTube to find a solution too but it still doesn’t play the animation. Its my first time scripting and animating a mesh so I basically have no clue on how to make it work.

This is how I did it,
image

3 Likes

You don’t need a Humanoid if you have an AnimationController.

Place the AnimationController in the root of the model, and place an animator in the animation controller. User Animator:LoadAnimation() instead of Humanoid:LoadAnimation(). Your code should work if the animation was constructed properly.

3 Likes

Thanks for helping! I finally figured it out. The script worked and also the animation I created was constructed poorly too so it wouldn’t play.

1 Like

May i ask can i have the script you got to work because im having the same issues

I know this is a bit late, but make sure your character has AnimationContoroller and that it’s placed in the character’s root part. Then add Animator inside of the AnimationController, (manually or with server script). It’s ok to have a humanoid too in your character.

Then in the local script do (for example):

local char = game.Players.LocalPlayer.Character
local walk = --(find your animation here)
local animator = char:WaitForChild("HumanoidRootPart").AnimationController.Animator
local walkAnim = animator:LoadAnimation(walk)

walkAnim:Play()

This way it worked for me.

1 Like

I think the AnimationController is supposed to be parented to the character.

I tried to place the AnimationController in the character but for some reason it doesn’t work like that. :thinking:

Ah, it’s because there’s another issue: there’s a humanoid. It’s supposed to be char.Humanoid.Animator.