Humanoid:LoadAnimation() deprecated, New animation alternatives?

I noticed today that the :LoadAnimation() function on Humanoid instances is now deprecated. Are there any non-deprecated alternatives to it, or anything that Roblox replaced it with?

1 Like

Use humanoid.Animator to load your animations

From the API:

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
2 Likes

Use the Animator object inside of the humanoid

Eg.
Humanoid.Animator:LoadAnimation()

1 Like

Use Humanoid.Animatior:LoadAnimation():

if Humanoid:FindFirstChild("Animator") then
   Humanoid.Animatior:LoadAnimation()
else
   warn("No animator found inside humanoid: " .. Humanoid:GetFullName())
end
1 Like

you could do this if animator returns nil:

	local animator = humanoid:FindFirstChildOfClass("Animator")
	if not animator then
        animator = Instance.new('Animator', humanoid)
	end
    local animationTrack = animator:LoadAnimation(animation)
	animationTrack:Play()
	return animationTrack
1 Like

Pulled the code right from the API but yes, that is a way to do it :+1: