so when i activate my tool and unequip my tool, my action animation still plays.
local sword = script.Parent
local swordRemote = sword:WaitForChild("swordRemote")
local Animtrack = nil
local anims = {
Idle = 110871183700731,
Slash = 107277601477337,
equipped = false,
DB = false
}
swordRemote.OnServerEvent:Connect(function(p, equipState)
local c = p.Character
local h = c:WaitForChild("Humanoid")
local animator:Animator = h:WaitForChild("Animator")
local anim = sword:WaitForChild("Animation")
if equipState == "equip" then
anims.equipped = true
anim.AnimationId = "rbxassetid://"..anims.Idle
Animtrack = animator:LoadAnimation(anim)
Animtrack:Play()
elseif equipState == "action" then
if anims.equipped == true then
if not anims.DB then
anims.DB = true
anim.AnimationId = "rbxassetid://"..anims.Slash
Animtrack = animator:LoadAnimation(anim)
Animtrack:Play()
Animtrack.Ended:Connect(function()
anims.DB = false
end)
end
end
elseif equipState == "unequip" then
anims.equipped = false
if Animtrack then
Animtrack:Stop()
Animtrack = nil
end
end
end)