I've been working on a tool with custom walk and idle anims. The problem is, the running anim won't stop playing while the tool is equipped! The anims are supposed to only play while the tool is equipped, which went fine. The only problem is this walking animation one. It won't stop playing while you have the tool equipped. Below is the code for the weapon.
canAttack = true
local p = game.Players.LocalPlayer
local c = p.Character or p.CharacterAdded:Wait()
local Humanoid = c:WaitForChild('Humanoid')
repeat wait() until Humanoid ~= nil
local attack = Humanoid:LoadAnimation(script.Attack)
local walking = Humanoid:LoadAnimation(script.Walking)
local idle = Humanoid:LoadAnimation(script.Idle)
local moving = script.Parent.Moving
script.Parent.Equipped:Connect(function()
script.Parent.Handle.Unsheath:Play()
moving.Value = false
equipped = true
end)
Humanoid.Running:connect(function(value)
if value <= 0 then
moving.Value = false
elseif value > 0 then
moving.Value = true
end
end)
moving.Changed:Connect(function()
if moving.Value == true and equipped == true then
walking.Looped = true
idle.Looped = false
idle:Stop()
walking:Play()
end
if moving == false and equipped == true then
walking.Looped = false
walking:Stop()
idle.Looped = true
idle:Play()
end
end)
script.Parent.Activated:Connect(function()
local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Attack)
if canAttack == true then
script.Parent.Handle.Swing:Play()
attack:Play()
canAttack = false
wait(.4)
attack:Stop()
canAttack = true
script.Parent.CanDamage.Value = true
end
end)
script.Parent.Unequipped:Connect(function()
equipped = false
idle.Looped = false
idle:Stop()
walking.Looped = false
walking:Stop()
end)

1 comment
Crap. Thanks, man! Gonna try this out. I hate when I make this mistake of not saying .Value!