Why wont the animation stop right after i drop the tool?

so the anim still plays even if i drop the tool.

local tool = script.Parent
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=101205647665916" 
local track

local function stopAnimation()
	if track then
		track:Stop()
		track = nil
	end
end

tool.Equipped:Connect(function()
	local character = tool.Parent
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if humanoid then
		track = humanoid:LoadAnimation(anim)
		track.Priority = Enum.AnimationPriority.Movement
		track.Looped = true
		track:Play()
	end
end)

tool.Unequipped:Connect(stopAnimation)

tool.AncestryChanged:Connect(function()
	if not tool:IsDescendantOf(game.Players) then
		stopAnimation()
	end
end)


1 Like

ā€“ Iā€™m, sure Movement is used for moving character, mainly for walking, jumping and so
track.Priority = Enum.AnimationPriority.Movement

ā€“ while Enum.AnimationPriority.Action is mainly to override walking and jumping and idle animations
track.Priority = Enum.AnimationPriority.Action

ā€“ Not sure if it will work buy try it out :slightly_smiling_face:

it doesnt work mann i just disabled the tool dropping so that it wouldnt be a problem anymore

1 Like