Animation Track plays, but character doesn't animate

  1. What do you want to achieve? Keep it simple and clear!
    I want the character inside the WorldModel to animate.

  2. What is the issue? Include screenshots / videos if possible!
    AnimationTrack is playing, but the animation do not appear to play (It keeps playing the Idle animation from my animation package)

  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    I’ve tried switching the character model to a default Rig
    Looked for solutions through many different dev forum posts

if Character then
            Character.Archivable = true
            local charClone : Model = Character:Clone()
            charClone.Parent = worldModel
            charClone:PivotTo(CFrame.new(0,3,0))
            task.wait()
            
            local id = dance.Id
            if id then
                charClone.Archivable = false
                local humanoid = charClone:FindFirstChild("Humanoid")
                local animator = humanoid:FindFirstChildOfClass("Animator")
                local animation = Instance.new("Animation")
                animation.AnimationId = dance.Id
                local track : AnimationTrack = animator:LoadAnimation(animation)
                track.Looped = true
                track.Priority = Enum.AnimationPriority.Action4
                track:Play()
                animation:Destroy()
                
                print(track.IsPlaying) -- it prints true
            end
        end

It’s because your cloning the animate script inside the character clone. Delete the animate script inside the clone before you play the animation.

if Character then
	
	Character.Archivable = true

	local charClone : Model = Character:Clone()
	charClone.Parent = worldModel
	charClone:PivotTo(CFrame.new(0,3,0))
	
	local id = dance.Id
	
	if id then
		charClone.Archivable = false
		
		for i, v in pairs(charClone:GetDescendants()) do -- Remove all scripts inside the clone
			if v:IsA("Script") or v:IsA("LocalScript") then
				v:Destroy()
			end
		end
		
		local humanoid = charClone:FindFirstChild("Humanoid")
		local animator = humanoid:FindFirstChildOfClass("Animator")
		
		local animation = Instance.new("Animation")
		animation.AnimationId = dance.Id
		
		local track : AnimationTrack = animator:LoadAnimation(animation)
		
		track.Looped = true
		track.Priority = Enum.AnimationPriority.Action4
		
		track:Play()
		animation:Destroy()

		print(track.IsPlaying) -- it prints true
	end
end

I forgot to mention, but I already tried this. It only stops the idle animation, and my animation still doesn’t play.

Weird, removing the scripts seem to have fixed the issue for me. Could be something else besides the script that is affecting it.

1 Like

I’ve found that the animation doesn’t load properly, when i print the AnimationTrack’s Length it is 0 so it stops instantly, but i don’t know why. I loaded the same animation on other script on server-side and it worked perfectly. (the Length stays 0 and never changes)

I found a fix. The animation wasnt loading properly, so i used the ContentProvider Service to Preload it and it started working.

 if Character then
                Character.Archivable = true

                local charClone : Model = Character:Clone()
                charClone.Parent = worldModel
                charClone:PivotTo(CFrame.new(0,3,0))
                local id = dance.Id

                if id then
                    Character.Archivable = false

                    local humanoid : Humanoid = charClone:FindFirstChild("Humanoid")
                    local animator = humanoid:FindFirstChildOfClass("Animator")

                    local animation = Instance.new("Animation")
                    animation.AnimationId = dance.Id

                    ContentProvider:PreloadAsync({animation})

                    local track : AnimationTrack = animator:LoadAnimation(animation)

                    track.Looped = true
                    track.Priority = Enum.AnimationPriority.Action4

                    track:Play()
                    animation:Destroy()
                end

            end
1 Like

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