"AnimationTrack is not a valid member of Animation"

I’m trying to get an NPC that will change animations at different walk speeds (Like idle (0), walk (6) and run (15). However, the animation doesn’t play when play-testing and in the output it says “AnimationTrack is not a valid member of Animation”. What?
Code:

local Animation = game.Workspace.MIKKLE2.Humanoid.Animator
local Mikkle = Animation.Parent.Parent
local Humanoid = script.Parent.Humanoid
local RunAnim = Humanoid.Animator.RunAnim
local IdleAnim = Humanoid.Animator.IdleAnim

Mikkle.Humanoid.Running:Connect(function(speed)
	if Mikkle.Humanoid.WalkSpeed > 0 then
		Mikkle.Humanoid:LoadAnimation(RunAnim)
		RunAnim.AnimationTrack:Play()
	end
end)

try this

local Animation = game.Workspace.MIKKLE2.Humanoid.Animator
local Mikkle = Animation.Parent.Parent
local Humanoid = script.Parent.Humanoid
local RunAnim = Humanoid.Animator.RunAnim
local IdleAnim = Humanoid.Animator.IdleAnim

Mikkle.Humanoid.Running:Connect(function(speed)
	if Mikkle.Humanoid.WalkSpeed > 0 then
		local a = Mikkle.Humanoid:LoadAnimation(RunAnim)
		a:Play()
	end
end)
1 Like

Worked! No clue how, but thank you (can you tell how im begigng psls)

to play an animation you have to “save” the animationtrack in a variable

something like this

local AnimationTrack = Animator:LoadAnimation(Animation) --I think Humanoid:LoadAnimation is deprecated
AnimationTrack:Play()

(sorry for bad english)

That’s fine, but thank you. I was stuck on this question.

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