Animation bug - Stops when player moves

I am creating a gun system and there is a bug where when a player moves the animation stops.
Unfortunately I believe that my video is too large to upload, so I can’t show one.
Here is some code in a script inside the tool itself

local tool = script.Parent.Parent.Parent

local player
local getName = script.Parent.Parent:WaitForChild("Remotes"):WaitForChild("getName")

	player = playerInstance

	local character = player.Character or player.Character:Wait()
	local hum = character:WaitForChild("Humanoid")
	local Animator = hum:WaitForChild("Animator")

	local holdAnimation ="Animation")
	holdAnimation.AnimationId = "rbxassetid://6977809658"

	local holdAnimationTrack = Animator:LoadAnimation(holdAnimation)
	print("Animation Loaded")
	holdAnimationTrack.Priority = Enum.AnimationPriority.Action
	holdAnimationTrack.Looped = true
1 Like

I never delved that far into the Animation / AnimationTrack API, but from my knowledge it looks to me that the priority of your animation could be causing your problem

Why not experiment with different priorities for your track? You can try Enum.AnimationPriority.Movement

You should also “load” your animation outside of the function passed in tool.Equipped.Connect, it is completely unnecessary to “declare” constant variables in a scope

1 Like

Thank you, I will try that later.