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)