Deprecating LoadAnimation on Humanoid and AnimationController

I have read that LoadAnimation is deprecating and recommended not to use, I am trying to understand what the best way is to animate.

Do you code the animation via a Server or local script?

Does anyone have an example?

Thanks

There’s an Animator object instead, which is a child of Humanoid. You can use that to load animations.

you just do Humanoid.Animator:LoadAnimation instead of Humanoid:LoadAnimation.

Thanks,

This is my server code but when I run nothing happens?

local function playAnimationFromServer(character, animation)
	print("In playAnimationFromServer")
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if humanoid then
		print("humanoid")
		local animator = humanoid:FindFirstChildOfClass("Animator")
		if animator then
			print("Animator")
			local animationTrack = animator:LoadAnimation(animation)
			animationTrack:Play()
			return animationTrack
		end
	end
end

local anim = "rbxassetid://6985833465"
local npc = game.Workspace:WaitForChild("Cat")

playAnimationFromServer(npc, anim)

No clue. It’s probably something else, such as the animation is played but very early that you weren’t able to catch the animation? Maybe the animation isn’t looped?

i didn’t know you can play animations with their id strings, i tought you can only use the animation instance