Client Animation Issue

I have a function which creates characters using HumanoidDescription:

local function CreateCharacter(UserId, Slot)
	if (CharactersLoaded[Slot] ~= nil) then
		local Character = CharactersLoaded[Slot]
		Character:Destroy()
	end
	
	local Character = DefaultRig:Clone()
	local Humanoid = Character:WaitForChild("Humanoid")
	local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

	local HumanoidDescription = Players:GetHumanoidDescriptionFromUserId(UserId)

	Character.Parent = CharactersFolder

	Humanoid:ApplyDescription(HumanoidDescription)
	HumanoidRootPart.CFrame = CharacterSpawns[Slot]
	
	local Humanoid = Character:WaitForChild("Humanoid")
	Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
	
	local Animator = Humanoid:FindFirstChild("Animator")
	
	if (Animator == nil) then
		Animator = Instance.new("Animator")
		Animator.Parent = Humanoid
	end
	
	local IdleAnimation = Instance.new("Animation")
	IdleAnimation.AnimationId = "rbxassetid://"..HumanoidDescription.IdleAnimation
	
	local IdleTrack :AnimationTrack = Humanoid:LoadAnimation(IdleAnimation)
	IdleTrack.Looped = true
	IdleTrack:Play()
	
	CharactersLoaded[Slot] = Character
end

Everything works besides the animation part; (Simplified function for readability)

local function CreateCharacter(UserId, Slot)
	
	local Character = DefaultRig:Clone()
	local Humanoid = Character:WaitForChild("Humanoid")
	local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

	local HumanoidDescription = Players:GetHumanoidDescriptionFromUserId(UserId) -- Should apply animations by default???

	Humanoid:ApplyDescription(HumanoidDescription)
	
	local Humanoid = Character:WaitForChild("Humanoid")	
	local Animator = Humanoid:FindFirstChild("Animator") -- Attempt to load an animator and play animations that way
	
	if (Animator == nil) then
		Animator = Instance.new("Animator")
		Animator.Parent = Humanoid
	end
	
	local IdleAnimation = Instance.new("Animation")
	IdleAnimation.AnimationId = "rbxassetid://"..HumanoidDescription.IdleAnimation
	
	local IdleTrack :AnimationTrack = Humanoid:LoadAnimation(IdleAnimation)
	IdleTrack.Looped = true
	IdleTrack:Play() -- Doesn't work
end

Characters load fine, they just don’t animate. No errors or anything:

This is a LocalScript, being viewed from client perspective.

Any ideas on how to troubleshoot? I tried checking different Ids, changing track properties, e.t.c.

Feel free to reply and ask for additional info. Any sort of help appreciated! :slight_smile:

I’m pretty sure when characters are created, their humanoid root part is anchored. Maybe add a line unanchoring the humanoid root part

HumanoidRootPart and all other children of the character are unanchored.

i might be full of crap on this one, but why do you have an if statement that checks if the animator is nil

doesnt it mean that it doesnt exist?

also is the code here the same from the one from studios cause i notice a typo

	local Animator = Humanoid:FindFirstChild("Animator") -- Looks for animator
	
	if (Animator == nil) then -- If one doesn't exist
		Animator = Instance.new("Animator") -- Create one
		Animator.Parent = Humanoid -- Parent it to the Humanoid
	end

I found this post: Deprecating LoadAnimation on Humanoid and AnimationController

It states that the use of Humanoid and AnimationController are deprecated and should not be used. Instead, an Animator instance created by a server should be used by the client. In my situation, this isn’t possible as all characters are local and not replicated.

Just because it’s deprecated doesn’t mean it wont still work

try loading the animation to the humanoid

if it doesnt work i tried :pensive: