Animation not working

I would like for animation to properly work, for some odd reason even though my animations are set to a higher priority, plus trying to use Humanoid instead of Animator my code does not work:

While testing it worked at one point, but now completely stopped working. The animation is also looped and is shown easily. No warnings or errors have appeared.

local loopedAnim

function playAnimation(animationName, store)
	if not LocalAnimator then return warn("No animator found!") end
	local Animation = AnimationFolder:FindFirstChild(animationName)
	if not Animation then return warn("No animation found!") end
	
	print(LocalAnimator:GetFullName())

	print("Playing animation!")
	
	local animationTrack : AnimationTrack = LocalAnimator:LoadAnimation(Animation)
	animationTrack.Priority = Enum.AnimationPriority.Action4
	animationTrack:Play(0.05)
	
	Tracks[animationName] = animationTrack
	
	if animationTrack.Looped then 
		print("Is looped!")
		if loopedAnim and Tracks[loopedAnim] then 
			print("Stop looped animation!")
			Tracks[loopedAnim]:Stop() 
			Tracks[loopedAnim] = nil 
		end
		loopedAnim = animationName
	end
	
	return animationTrack
end

....

tool.Equipped:Connect(function()
	gui.Parent = LocalPlayer.PlayerGui
	gui.Enabled = false
	LocalCharacter = tool.Parent or LocalPlayer.Character
	LocalHumanoid, LocalRoot = LocalCharacter:FindFirstChild("Humanoid") or LocalCharacter:FindFirstChildWhichIsA("Humanoid") or LocalCharacter:WaitForChild("Humanoid"), LocalCharacter:FindFirstChild("HumanoidRootPart")
	LocalAnimator = LocalHumanoid and (LocalHumanoid:FindFirstChildWhichIsA("Animator") or LocalHumanoid:FindFirstChild("Animator") or LocalHumanoid:WaitForChild("Animator"))
	print("Animator assigned: ", LocalAnimator.Name)
	playAnimation("RodIdle", true)
end)
1 Like

You have some prints in your code. Did anything print when you run the code?

This might be the issue.

if animationTrack.Looped then
print(“Is looped!”)
if loopedAnim and Tracks[loopedAnim] then
print(“Stop looped animation!”)
Tracks[loopedAnim]:Stop()
Tracks[loopedAnim] = nil
end
loopedAnim = animationName
end

This is part of your code. Your animation is looped right? This part checks if it’s looped and if the animation is in a dictionary. Since both are true, it continues and stops the animation?