AnimationTrack:Play() not working

local Bun = script.Parent
local Humanoid = Bun:WaitForChild('Humanoid')
local Animator = Bun:WaitForChild('AnimationController'):WaitForChild('Animator')
local RootPart = Bun:WaitForChild('HumanoidRootPart')

local AnimFolder = Humanoid:WaitForChild('Animations')

local Animations = {}

for i, Animation in AnimFolder:GetChildren() do
	
	local Anim = Animator:LoadAnimation(Animation)
	
	table.insert(Animations, Anim)
	
end

function GetAnimation(Animation)

	for i, v in Animations do
		
		if v.Name == Animation then
			
			return v
			
		end
		
	end
	
	return 'Idle'

end

GetAnimation('Idle'):Play()

print('IdleAnimation?')

no error is given, but the animation does not play. The output is only the print statement at the end.

Ok i might be confused, correct me if im wrong, but it looks like youre doing some stuff incorrectly.

For one, youre doing a for loop, then not using it at all. And you rlly dont need to use a function like that for animations, i dont think.

The animation docs might be able to help.

Also make sure youre using the correct script (server or local)

Sometimes animations won’t play when played the first time as they need to be fully loaded. Try running the function twice. Confirm that GetAnimation is returning an AnimationTrack and check all its properties to verify it’s the instance you’re looking for.

i fixed it by moving the animator into the humanoid

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