I made a sword which works perfectly fine with it's slashing and idle animation, but when i unequip the sword the idle animation remains active.How do i fix it?
Here is the script:
local CanAttack = true
script.Parent.Equipped:connect(function()
local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Attack)
idle:Play()
end)
script.Parent.Activated:connect(function()
local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Attack)
if CanAttack == true then
attack:Play()
idle:Stop()
CanAttack = false
wait(1)
attack:Stop()
idle:Play()
CanAttack = true
script.Parent.CanDamage.Value = true
end
end)

3 comments
I am thankful to your answer but it didn't work the situation still remains the same
Okay, can you set the LoadAnimations on top of your script and try again?
(not inside the equipped event