(Bad English Warning)
I am trying to create script which will play idle and run animations when holding a tool
However when idle animaton plays ones it just stops
local tool = script.Parent
local animIdle = Instance.new("Animation")
local animRun=Instance.new("Animation")
animIdle.AnimationId = "http://www.roblox.com/Asset?ID=130441953020423"
animRun.AnimationId="http://www.roblox.com/Asset?ID=113670739567202"
local character=script.Parent.Parent.Parent.Character
local trackIdle=character.Humanoid.Animator:LoadAnimation(animIdle)
trackIdle.Priority=Enum.AnimationPriority.Idle
trackIdle.Looped=true
local trackRun=character.Humanoid.Animator:LoadAnimation(animRun)
trackRun.Priority=Enum.AnimationPriority.Movement
trackRun.Looped=true
character.AttributeChanged:Connect(function()
if character:GetAttribute("HoldingSword") and character:GetAttribute("Moving") then
if trackIdle then
trackIdle:Stop()
end
trackRun:Play()
elseif character:GetAttribute("HoldingSword") then
if trackRun then
trackRun:Stop()
end
trackIdle:Play()
end
end)
tool.Unequipped:Connect(function()
trackRun:Stop()
trackIdle:Stop()
end)