Properly playing animtions?

Hello, I recently noticed that the LoadAnimation() method of the humanoid was deaprecated, so I am wondering what the new proper way of playing an animation would be since I could not find anything regarding that. Thanks.

I actually wasn’t aware of this deprecation until I read your post!

It looks like they are wanting to move away from the Humanoid’s LoadAnimation method in favor of the LoadAnimation method of the Animator class.

As far as I can tell from the documentation, it looks like it’s a near drop-in replacement for Humanoid animation, and you can simply use Animator:LoadAnimation(animation_object) to retrieve a playable AnimationTrack.

You should be able to achieve what you want via the code provided at the bottom of the Animator class page. I’ll include the code below just for easy reference:

    local function playAnimationFromServer(character, animation)
    	local humanoid = character:FindFirstChildOfClass("Humanoid")
    	if humanoid then
    		-- need to use animation object for server access
    		local animator = humanoid:FindFirstChildOfClass("Animator")
    		if animator then
    			local animationTrack = animator:LoadAnimation(animation)
    			animationTrack:Play()
    			return animationTrack
    		end
    	end
    end
1 Like