I'm New to AnimationController, and it isn't working as expected

  1. What do you want to achieve?
    I have a customer character which I am moving around the world by changing the CFrame of the HumanoidRootPart.

  2. Structure of character:
    image

  • Only the HumanoidRootPart is anchored.
  • The rest of the parts are either welded or rigged.
  • The PrimaryPart of the model is set to HumanoidRootPart.
  • Animation priority is set to Action.
  • It is inside a Group game, and the animation is published under the group.
  1. What is the issue? Include screenshots / videos if possible!
    This is the animation I am trying to run:

The character tweens (Via CFrame of HumanoidRootPart) but does not run the animation.

  1. What solutions have you tried so far?
  • I have tried all the requirements I could find for AnimationController, and the rigging is fine I believe because it allows me to animate the character in Animation Editor just fine and export that.

The following script is executed when the character has been added to the Workspace. It is run on the server-side, as per AnimationController | Roblox Creator Documentation

function animateCustomer(newCustomer)
    if not newCustomer then return end
    local animControl = newCustomer:WaitForChild("AnimationController");
    if not animControl then return end

    local animator = Instance.new("Animator");
    animator.Parent = animControl;
    if not animator then return end

    local idleAnimId = animControl:GetAttribute("IdleAnim");
    if not idleAnimId then return end

    local idleAnim = Instance.new("Animation");
    idleAnim.AnimationId = idleAnimId;

    _UF.AnchorObject(newCustomer); -- This anchors the HumanoidRootPart
    local animTrack = animControl:LoadAnimation(idleAnim);
    animTrack.Stopped:Connect(function() 
        print("Why did the animation stop?")
    end)
    animTrack.DidLoop:Connect(function()
        print("Looping?")
    end)
    animTrack:Play();
end

Debugging info:
The “Looping?” gets printed multiple times. But nothing happens.

What am I missing here?

I have no clue what might be wrong.

Ideas:

Don’t anchor any parts and try again.

Load animations from keyframes instead, to see if the animation publishing went wrong: Use. KeyframeSequenceProvider:RegisterKeyframeSequence()

Good luck. :slight_smile:

It’s definitely something to do with the scripting or flow. If I start the world with a copy of the model, anchored, and use this script:

local rig = script.Parent

-- Create a new "Animation" instance and assign an animation asset ID
local kickAnimation = Instance.new("Animation")
kickAnimation.AnimationId = "rbxassetid://12280659273"

-- Create a new "AnimationController" and "Animator"
local animationController = Instance.new("AnimationController")
animationController.Parent = rig
local animator = Instance.new("Animator")
animator.Parent = animationController

-- Load the animation onto the animator
local kickAnimationTrack = animator:LoadAnimation(kickAnimation)

-- Play the animation track
kickAnimationTrack:Play()

-- If a named event was defined for the animation, connect it to "GetMarkerReachedSignal()"
--kickAnimationTrack:GetMarkerReachedSignal("KickEnd"):Connect(function(paramString)
--	print(paramString)
--end)

Then the animation plays on that object.
I think the issue is that when I move the HumanoidRootPart, it breaks the animation for some reason? Why could this be?

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.